]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 years agoweekly.2011-09-21 weekly.2011-09-21
Andrew Gerrand [Thu, 22 Sep 2011 05:06:10 +0000 (15:06 +1000)]
weekly.2011-09-21

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5075050

12 years agoexp/template/html: elide comments in template source.
Mike Samuel [Thu, 22 Sep 2011 04:38:40 +0000 (21:38 -0700)]
exp/template/html: elide comments in template source.

When templates are stored in external files, developers often embed
comments to explain&|disable code.

  <!-- Oblique reference to project code name here -->
  {{if .C}}...{{else}}<!-- commented out default -->{{end}}

This unnecessarily increases the size of shipped HTML and can leak
information.

This change elides all comments of the following types:
1. <!-- ... --> comments found in source.
2. /*...*/ and // comments found in <script> elements.
3. /*...*/ and // comments found in <style> elements.

It does not elide /*...*/ or // comments found in HTML attributes:
4. <button onclick="/*...*/">
5. <div style="/*...*/">

I can find no examples of comments in attributes in Closure Templates
code and doing so would require keeping track of character positions
post decode in

  <button onclick="/&#42;...*/">

To prevent token joining, /*comments*/ are JS and CSS comments are
replaced with a whitespace char.
HTML comments are not, but to prevent token joining we could try to
detect cases like
   <<!---->b>
   </<!---->b>
which has a well defined meaning in HTML but will cause a validator
to barf.  This is difficult, and this is a very minor case.
I have punted for now, but if we need to address this case, the best
way would be to normalize '<' in stateText to '&lt;' consistently.

The whitespace to replace a JS /*comment*/ with depends on whether
there is an embedded line terminator since
    break/*
    */foo
    ...
is equivalent to
    break;
    foo
    ...
while
    break/**/foo
    ...
is equivalent to
    break foo;
    ...

Comment eliding can interfere with IE conditional comments.
http://en.wikipedia.org/wiki/Conditional_comment

<!--[if IE 6]>
<p>You are using Internet Explorer 6.</p>
<![endif]-->

/*@cc_on
  document.write("You are using IE4 or higher");
@*/

I have not encountered these in production template code, and
the typed content change in CL 4962067 provides an escape-hatch
if conditional comments are needed.

R=nigeltao
CC=golang-dev
https://golang.org/cl/4999042

12 years agoA&C: Add Paul Sbarra.
David Symonds [Thu, 22 Sep 2011 03:05:13 +0000 (13:05 +1000)]
A&C: Add Paul Sbarra.

R=golang-dev, adg
CC=golang-dev, sbarra.paul
https://golang.org/cl/5044045

12 years agoexp/template/html: simplify transition functions
Mike Samuel [Thu, 22 Sep 2011 02:04:41 +0000 (19:04 -0700)]
exp/template/html: simplify transition functions

This simplifies transition functions to make it easier to reliably
elide comments in a later CL.

Before:
- transition functions are responsible for detecting special end tags.
After:
- the code to detect special end tags is done in one place.

We were relying on end tags being skipped which meant we were
not noticing comments inside script/style elements that contain no
substitutions.
This change means we will notice all such comments where necessary,
but stripTags will notice none since it does not need to.  This speeds
up stripTags.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5074041

12 years agotest: match gccgo error messages
Ian Lance Taylor [Thu, 22 Sep 2011 00:25:48 +0000 (17:25 -0700)]
test: match gccgo error messages

bug363.go:13:12: error: invalid context-determined non-integer type for shift operand
bug363.go:16:12: error: invalid context-determined non-integer type for shift operand

pointer.go:34:6: error: incompatible type in initialization (pointer to interface type has no methods)
pointer.go:36:6: error: incompatible type in initialization

method2.go:15:1: error: invalid pointer or interface receiver type
method2.go:16:1: error: invalid pointer or interface receiver type
method2.go:21:1: error: invalid pointer or interface receiver type
method2.go:22:1: error: invalid pointer or interface receiver type
method2.go:28:15: error: type ‘*Val’ has no method ‘val’
method2.go:33:11: error: reference to undefined field or method ‘val’

shift1.go:19:16: error: invalid context-determined non-integer type for shift operand
shift1.go:24:19: error: invalid context-determined non-integer type for shift operand
shift1.go:25:17: error: invalid context-determined non-integer type for shift operand
shift1.go:18:18: error: shift of non-integer operand
shift1.go:26:13: error: floating point constant truncated to integer
shift1.go:33:15: error: integer constant overflow
shift1.go:34:15: error: integer constant overflow
shift1.go:35:17: error: integer constant overflow

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5081051

12 years agogodoc: simplify internal FileSystem interface
Robert Griesemer [Wed, 21 Sep 2011 22:12:06 +0000 (15:12 -0700)]
godoc: simplify internal FileSystem interface

- also fixed bug: ReadFile never closed the file before
- per suggestion by bradfitz

R=bradfitz
CC=golang-dev
https://golang.org/cl/5092047

12 years agogob: slightly simpler decodeUint
Robert Griesemer [Wed, 21 Sep 2011 21:47:00 +0000 (14:47 -0700)]
gob: slightly simpler decodeUint

R=r
CC=golang-dev
https://golang.org/cl/5089048

12 years agogob: slightly simpler code for encodeUint
Robert Griesemer [Wed, 21 Sep 2011 21:18:48 +0000 (14:18 -0700)]
gob: slightly simpler code for encodeUint

R=r
CC=golang-dev
https://golang.org/cl/5077047

12 years agobytes: fix Replace so it actually copies
Gustavo Niemeyer [Wed, 21 Sep 2011 15:36:17 +0000 (12:36 -0300)]
bytes: fix Replace so it actually copies

The documentation for bytes.Replace says it copies
the slice but it won't necessarily copy them.  Since
the data is mutable, breaking the contract is an issue.

We either have to fix this by making the copy at all
times, as suggested in this CL, or we should change the
documentation and perhaps make better use of the fact
it's fine to mutate the slice in place otherwise.

R=golang-dev, bradfitz, adg, rsc
CC=golang-dev
https://golang.org/cl/5081043

12 years agohttp: add a (disabled) test for TLS handshake timeouts
Brad Fitzpatrick [Wed, 21 Sep 2011 15:30:47 +0000 (08:30 -0700)]
http: add a (disabled) test for TLS handshake timeouts

It's currently broken and disabled, pending a fix
for Issue 2281.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5092045

12 years agoexp/template/html: fix bug, '<' normalization for text nodes that change context
Mike Samuel [Wed, 21 Sep 2011 05:55:14 +0000 (22:55 -0700)]
exp/template/html: fix bug, '<' normalization for text nodes that change context

R=nigeltao
CC=golang-dev
https://golang.org/cl/5080042

12 years agotest: match gccgo error messages
Ian Lance Taylor [Tue, 20 Sep 2011 23:47:17 +0000 (16:47 -0700)]
test: match gccgo error messages

Added a return to bug357.go to avoid an error which gccgo
reports but 6g does not.

bug353.go:16:14: error: reference to undefined identifer ‘io.ReadWriterCloser’

bug357.go:18:2: error: value computed is not used

bug358.go:14:11: error: imported and not used: ioutil
bug358.go:19:9: error: invalid use of type

bug359.go:25:14: error: redefinition of ‘a’
bug359.go:25:6: note: previous definition of ‘a’ was here
bug359.go:19:6: error: incompatible type in initialization (implicit assignment of ‘list.List’ hidden field ‘front’)

bug362.go:13:6: error: iota is only defined in const declarations
bug362.go:14:6: error: iota is only defined in const declarations
bug362.go:15:6: error: iota is only defined in const declarations

bug363.go:13:12: error: shift of non-integer operand
bug363.go:16:12: error: shift of non-integer operand

bug365.go:15:8: error: expected package

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5078046

12 years agotest: match gccgo error messages for bug349.go
Ian Lance Taylor [Tue, 20 Sep 2011 21:47:48 +0000 (14:47 -0700)]
test: match gccgo error messages for bug349.go

bug349.go:12:14: error: expected ‘;’ or ‘}’ or newline
bug349.go:12:2: error: not enough arguments to return

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5081047

12 years agotest: match gccgo error messages for goto.go and bug344.go
Ian Lance Taylor [Tue, 20 Sep 2011 21:45:54 +0000 (14:45 -0700)]
test: match gccgo error messages for goto.go and bug344.go

goto.go:39:2: error: goto jumps over declaration of ‘x’
goto.go:40:2: note: ‘x’ defined here
goto.go:57:2: error: goto jumps over declaration of ‘x’
goto.go:62:2: note: ‘x’ defined here
goto.go:77:2: error: goto jumps over declaration of ‘x’
goto.go:78:2: note: ‘x’ defined here
goto.go:87:2: error: goto jumps over declaration of ‘x’
goto.go:88:2: note: ‘x’ defined here
goto.go:114:2: error: goto jumps into block
goto.go:115:2: note: goto target block starts here
goto.go:125:2: error: goto jumps into block
goto.go:122:2: note: goto target block starts here
goto.go:130:2: error: goto jumps into block
goto.go:133:4: note: goto target block starts here
goto.go:142:2: error: goto jumps into block
goto.go:145:2: note: goto target block starts here
goto.go:179:2: error: goto jumps into block
goto.go:180:10: note: goto target block starts here
goto.go:186:2: error: goto jumps into block
goto.go:187:10: note: goto target block starts here
goto.go:194:2: error: goto jumps into block
goto.go:196:4: note: goto target block starts here
goto.go:205:3: error: goto jumps into block
goto.go:202:11: note: goto target block starts here
goto.go:211:3: error: goto jumps into block
goto.go:212:4: note: goto target block starts here
goto.go:219:3: error: goto jumps into block
goto.go:220:18: note: goto target block starts here
goto.go:227:3: error: goto jumps into block
goto.go:228:18: note: goto target block starts here
goto.go:241:3: error: goto jumps into block
goto.go:243:4: note: goto target block starts here
goto.go:290:2: error: goto jumps into block
goto.go:287:6: note: goto target block starts here
goto.go:299:2: error: goto jumps into block
goto.go:294:6: note: goto target block starts here
goto.go:306:2: error: goto jumps into block
goto.go:303:12: note: goto target block starts here
goto.go:313:2: error: goto jumps into block
goto.go:310:24: note: goto target block starts here
goto.go:320:2: error: goto jumps into block
goto.go:317:18: note: goto target block starts here
goto.go:327:2: error: goto jumps into block
goto.go:324:18: note: goto target block starts here
goto.go:334:2: error: goto jumps into block
goto.go:331:18: note: goto target block starts here
goto.go:341:2: error: goto jumps into block
goto.go:338:18: note: goto target block starts here
goto.go:395:2: error: goto jumps into block
goto.go:398:2: note: goto target block starts here
goto.go:403:2: error: goto jumps into block
goto.go:406:2: note: goto target block starts here
goto.go:413:2: error: goto jumps into block
goto.go:417:2: note: goto target block starts here
goto.go:424:3: error: goto jumps into block
goto.go:426:2: note: goto target block starts here
goto.go:436:3: error: goto jumps into block
goto.go:433:2: note: goto target block starts here
goto.go:492:2: error: goto jumps into block
goto.go:495:2: note: goto target block starts here
goto.go:500:2: error: goto jumps into block
goto.go:503:2: note: goto target block starts here
goto.go:510:2: error: goto jumps into block
goto.go:514:2: note: goto target block starts here
goto.go:521:3: error: goto jumps into block
goto.go:523:2: note: goto target block starts here
goto.go:533:3: error: goto jumps into block
goto.go:530:2: note: goto target block starts here

bug344.go:17:2: error: goto jumps into block
bug344.go:20:21: note: goto target block starts here

R=rsc
CC=golang-dev
https://golang.org/cl/5077044

12 years agosuffixarray: improved serialization code
Robert Griesemer [Tue, 20 Sep 2011 21:36:19 +0000 (14:36 -0700)]
suffixarray: improved serialization code

Use gobs to serialize indexes instead of encoding/binary.

Even with gobs, serialize data in slices instead of
applying gob to the entire data structure at once,
to reduce the amount of extra buffer memory needed
inside gob.

7x faster Write/Read for new BenchmarkSaveRestore
compared to old code; possibly because encoding/binary
is more expensive for int32 slice elements (interface
call to get little/big endian encoding), while gob's
encoding is fixed (unconfirmed).

new (using gobs):
suffixarray.BenchmarkSaveRestore        1 2153604000 ns/op

old (using encoding/binary):
suffixarray.BenchmarkSaveRestore        1 15118322000 ns/op

The actual serialized data is slightly larger then using
the old code for very large indices because full 32bit indices
require 5bytes using gobs instead of 4bytes (encoding/binary)
in serialized form.

R=r
CC=golang-dev
https://golang.org/cl/5087041

12 years agoreflect: add comment about the doubled semantics of Value.String.
Rob Pike [Tue, 20 Sep 2011 20:26:57 +0000 (13:26 -0700)]
reflect: add comment about the doubled semantics of Value.String.

R=rsc
CC=golang-dev
https://golang.org/cl/5091044

12 years agohttptest: add NewUnstartedServer
Brad Fitzpatrick [Tue, 20 Sep 2011 20:02:10 +0000 (13:02 -0700)]
httptest: add NewUnstartedServer

This allows testing TLS with different http.Server
options (timeouts, limits).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5094043

12 years agocodereview: save CL messages in $(hg root)/last-change
Russ Cox [Tue, 20 Sep 2011 18:56:15 +0000 (14:56 -0400)]
codereview: save CL messages in $(hg root)/last-change

Fixes #2279.

R=bradfitz, r, r
CC=golang-dev
https://golang.org/cl/5096042

12 years agogob: fix allocation for singletons.
Rob Pike [Tue, 20 Sep 2011 18:28:00 +0000 (11:28 -0700)]
gob: fix allocation for singletons.
Code was double-allocating in some cases.
Fixes #2267.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5093042

12 years agotest: match gccgo error message for bug337.go
Ian Lance Taylor [Tue, 20 Sep 2011 16:31:07 +0000 (09:31 -0700)]
test: match gccgo error message for bug337.go

bug337.go:17:2: error: value computed is not used

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5094042

12 years agoexp/ssh: refactor halfConnection to transport
Dave Cheney [Tue, 20 Sep 2011 16:21:50 +0000 (12:21 -0400)]
exp/ssh: refactor halfConnection to transport
        This CL generalises the pair of halfConnection members that the
        serverConn holds into a single transport struct that is shared by
        both Server and Client, see also CL 5037047.

        This CL is a replacement for 5040046 which I closed by accident.

R=agl, bradfitz
CC=golang-dev
https://golang.org/cl/5075042

12 years agoexp/template/html: change transition functions to return indices
Mike Samuel [Tue, 20 Sep 2011 03:52:14 +0000 (20:52 -0700)]
exp/template/html: change transition functions to return indices

Formulaic changes to transition functions in preparation for CL 5074041.
This should be completely semantics preserving.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5091041

12 years agohttp: fix TLS handshake blocking server accept loop
Brad Fitzpatrick [Tue, 20 Sep 2011 02:56:51 +0000 (19:56 -0700)]
http: fix TLS handshake blocking server accept loop

Fixes #2263

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5076042

12 years agoexp/template/html: allow commenting out of actions
Mike Samuel [Tue, 20 Sep 2011 02:52:31 +0000 (19:52 -0700)]
exp/template/html: allow commenting out of actions

Instead of erroring on actions inside comments, use existing escaping
pipeline to quash the output of actions inside comments.

If a template maintainer uses a comment to disable template code:

  {{if .}}Hello, {{.}}!{{end}}

->

  <!--{{if true}}Hello, {{.}}!{{end}}-->

will result in

  <!--Hello, !-->

regardless of the value of {{.}}.

In a later CL, comment elision will result in the entire commented-out
section being dropped from the template output.

Any side-effects in pipelines, such as panics, will still be realized.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5078041

12 years agoexp/template/html: define isComment helper
Mike Samuel [Tue, 20 Sep 2011 00:27:49 +0000 (17:27 -0700)]
exp/template/html: define isComment helper

Non semantics-changing refactoring in preparation for comment elision.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5071043

12 years agogob: don't allocate a slice if there's room to decode already
Rob Pike [Mon, 19 Sep 2011 23:55:08 +0000 (16:55 -0700)]
gob: don't allocate a slice if there's room to decode already
Fixes #2275.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5082041

12 years agodoc: when configuring gold for gccgo, use --enable-gold=default
Ian Lance Taylor [Mon, 19 Sep 2011 18:54:07 +0000 (11:54 -0700)]
doc: when configuring gold for gccgo, use --enable-gold=default

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5030057

12 years agohttp: always include Content-Length header, even for 0
Dave Grijalva [Mon, 19 Sep 2011 18:41:09 +0000 (11:41 -0700)]
http: always include Content-Length header, even for 0

fixes #2221

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4952052

12 years agosync/atomic: replace MFENCE with LOCK XADD
Dmitriy Vyukov [Mon, 19 Sep 2011 18:09:00 +0000 (11:09 -0700)]
sync/atomic: replace MFENCE with LOCK XADD
MFENCE was introduced only on the Pentium4 (SSE2),
while XADD was introduced on the 486.
Fixes #2268.

R=golang-dev, rsc
CC=fshahriar, golang-dev
https://golang.org/cl/5056045

12 years agosuffixarray: generate less garbage during construction
Eric Eisner [Mon, 19 Sep 2011 18:03:43 +0000 (11:03 -0700)]
suffixarray: generate less garbage during construction

Minorly improves runtime by about 2-3%

R=gri, jeff
CC=golang-dev
https://golang.org/cl/5052045

12 years agohttp: prevent DumpRequest from adding implicit headers
Brad Fitzpatrick [Mon, 19 Sep 2011 17:22:53 +0000 (10:22 -0700)]
http: prevent DumpRequest from adding implicit headers

Fixes #2272

R=rsc
CC=golang-dev
https://golang.org/cl/5043051

12 years agojson: clearer Unmarshal doc
Russ Cox [Mon, 19 Sep 2011 17:19:07 +0000 (13:19 -0400)]
json: clearer Unmarshal doc

R=r
CC=golang-dev
https://golang.org/cl/5056049

12 years agogc: disallow invalid map keys
Russ Cox [Mon, 19 Sep 2011 17:11:24 +0000 (13:11 -0400)]
gc: disallow invalid map keys

The algtype-based test broke when algtype
got a bit more fine-grained, so replace with
an explicit check for the invalid key types.

R=ken2
CC=golang-dev
https://golang.org/cl/5071041

12 years agohttp: check explicit wrong Request.ContentLength values
Brad Fitzpatrick [Mon, 19 Sep 2011 16:01:32 +0000 (09:01 -0700)]
http: check explicit wrong Request.ContentLength values

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5070041

12 years agocgo: cgo to use GOARCH from the environment, not runtime.GOARCH (otherwise it results...
Jaroslavas Počepko [Mon, 19 Sep 2011 15:50:59 +0000 (11:50 -0400)]
cgo: cgo to use GOARCH from the environment, not runtime.GOARCH (otherwise it results in necessity of having 8cgo and 6cgo)

R=rsc, adg
CC=golang-dev
https://golang.org/cl/4978061

12 years agogc: handle complex CONVNOP
Russ Cox [Mon, 19 Sep 2011 15:50:53 +0000 (11:50 -0400)]
gc: handle complex CONVNOP

Fixes #2256.

R=ken2
CC=golang-dev
https://golang.org/cl/5044047

12 years ago8l: remove left over debugging
Dave Cheney [Mon, 19 Sep 2011 15:50:45 +0000 (11:50 -0400)]
8l: remove left over debugging

        This line was triggering a null dereference warning
        under clang-3.0. The line was added in a46819aa9150
        but compared to it's sibling in 6l it appears to be
        leftover debugging.

R=rsc
CC=golang-dev
https://golang.org/cl/5049042

12 years agojson: skip nil in UnmarshalJSON and (for symmetry) MarshalJSON
Russ Cox [Mon, 19 Sep 2011 15:50:41 +0000 (11:50 -0400)]
json: skip nil in UnmarshalJSON and (for symmetry) MarshalJSON

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/5050049

12 years agonet: use /etc/hosts first when looking up IP addresses using native Go's dns resolver
Andrey Mirtchovski [Mon, 19 Sep 2011 15:50:31 +0000 (11:50 -0400)]
net: use /etc/hosts first when looking up IP addresses using native Go's dns resolver

Previously /etc/hosts would be ignored altogether, this change returns matching results
from that file without talking to a DNS server.

R=rsc
CC=golang-dev
https://golang.org/cl/5061042

12 years agoexp/norm: Adopt regexp to exp/regexp semantics.
Marcel van Lohuizen [Mon, 19 Sep 2011 15:30:19 +0000 (17:30 +0200)]
exp/norm: Adopt regexp to exp/regexp semantics.

R=rsc
CC=golang-dev
https://golang.org/cl/5046041

12 years agoexp/ssh: fix constant in package documentation
Dave Cheney [Mon, 19 Sep 2011 14:32:11 +0000 (10:32 -0400)]
exp/ssh: fix constant in package documentation

R=agl
CC=golang-dev
https://golang.org/cl/5030054

12 years ago crypto/bcrypt: new package
Jeff Hodges [Mon, 19 Sep 2011 14:29:02 +0000 (10:29 -0400)]
crypto/bcrypt: new package

A port of Provos and Mazières's adapative hashing algorithm. See http://www.usenix.org/events/usenix99/provos/provos_html/node1.html

R=bradfitz, agl, rsc, dchest
CC=golang-dev
https://golang.org/cl/4964078

12 years ago crypto/blowfish: exposing the blowfish key schedule
Jeff Hodges [Mon, 19 Sep 2011 14:21:34 +0000 (10:21 -0400)]
crypto/blowfish: exposing the blowfish key schedule

Mostly useful for the coming crypto/bcrypt package

R=bradfitz, agl, rsc, agl
CC=golang-dev
https://golang.org/cl/5013043

12 years agodoc: link to golang-france
Andrew Gerrand [Mon, 19 Sep 2011 05:36:06 +0000 (15:36 +1000)]
doc: link to golang-france

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5059046

12 years agotag release.r60.1
Andrew Gerrand [Mon, 19 Sep 2011 04:01:39 +0000 (14:01 +1000)]
tag release.r60.1

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5030045

12 years agodoc: update release.r60.1 notes
Andrew Gerrand [Mon, 19 Sep 2011 02:16:08 +0000 (12:16 +1000)]
doc: update release.r60.1 notes

R=dsymonds
CC=golang-dev
https://golang.org/cl/5045045

12 years agoexp/template/html: allow quotes on either side of conditionals and dynamic HTML names
Mike Samuel [Mon, 19 Sep 2011 02:10:15 +0000 (19:10 -0700)]
exp/template/html: allow quotes on either side of conditionals and dynamic HTML names

This addresses several use cases:

(1) <h{{.HeaderLevel}}> used to build hierarchical documents.
(2) <input on{{.EventType}}=...> used in widgets.
(3) <div {{" dir=ltr"}}> used to embed bidi-hints.

It also makes sure that we treat the two templates below the same:

<img src={{if .Avatar}}"{{.Avatar}}"{{else}}"anonymous.png"{{end}}>
<img src="{{if .Avatar}}{{.Avatar}}{{else}}anonymous.png{{end}}">

This splits up tTag into a number of sub-states and adds testcases.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5043042

12 years agoexp/template/html: normalize '<' in text and RCDATA nodes.
Mike Samuel [Sun, 18 Sep 2011 19:04:40 +0000 (12:04 -0700)]
exp/template/html: normalize '<' in text and RCDATA nodes.

The template

  <{{.}}

would violate the structure preservation property if allowed and not
normalized, because when {{.}} emitted "", the "<" would be part of
a text node, but if {{.}} emitted "a", the "<" would not be part of
a text node.

This change rewrites '<' in text nodes and RCDATA text nodes to
'&lt;' allowing template authors to write the common, and arguably more
readable:

    Your price: {{.P1}} < list price {{.P2}}

while preserving the structure preservation property.

It also lays the groundwork for comment elision, rewriting

    Foo <!-- comment with secret project details --> Bar

to

    Foo  Bar

R=nigeltao
CC=golang-dev
https://golang.org/cl/5043043

12 years agoexp/template/html: recognize whitespace at start of URLs.
Mike Samuel [Sun, 18 Sep 2011 18:55:14 +0000 (11:55 -0700)]
exp/template/html: recognize whitespace at start of URLs.

HTML5 uses "Valid URL potentially surrounded by spaces" for
attrs: http://www.w3.org/TR/html5/index.html#attributes-1

    <a href=" {{.}}">

should be escaped to filter out "javascript:..." as data.

R=nigeltao
CC=golang-dev
https://golang.org/cl/5027045

12 years agoexp/ssh: new package.
Adam Langley [Sat, 17 Sep 2011 19:57:24 +0000 (15:57 -0400)]
exp/ssh: new package.

The typical UNIX method for controlling long running process is to
send the process signals. Since this doesn't get you very far, various
ad-hoc, remote-control protocols have been used over time by programs
like Apache and BIND.

Implementing an SSH server means that Go code will have a standard,
secure way to do this in the future.

R=bradfitz, borman, dave, gustavo, dsymonds, r, adg, rsc, rogpeppe, lvd, kevlar, raul.san
CC=golang-dev
https://golang.org/cl/4962064

12 years agoarchive/tar: document Header fields and Type flags
Mike Rosset [Sat, 17 Sep 2011 18:43:06 +0000 (11:43 -0700)]
archive/tar: document Header fields and Type flags

Documentation more along the lines of os.FileInfo
Fixes #2180.

R=golang-dev, dsymonds
CC=golang-dev, mike.rosset
https://golang.org/cl/4958055

12 years agoruntime: increase stack system space on windows/amd64
Hector Chu [Sat, 17 Sep 2011 10:39:29 +0000 (20:39 +1000)]
runtime: increase stack system space on windows/amd64

gotest src/pkg/exp/template/html was crashing because the exception handler overflowed the goroutine stack.

R=alex.brainman, golang-dev
CC=golang-dev
https://golang.org/cl/5031049

12 years agoruntime/pprof: enable test on windows
Hector Chu [Sat, 17 Sep 2011 08:00:32 +0000 (18:00 +1000)]
runtime/pprof: enable test on windows

R=alex.brainman
CC=golang-dev
https://golang.org/cl/5047045

12 years agoruntime: implement pprof support for windows
Hector Chu [Sat, 17 Sep 2011 07:57:59 +0000 (17:57 +1000)]
runtime: implement pprof support for windows

Credit to jp for proof of concept.

R=alex.brainman, jp, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/4960057

12 years agofilepath: fix Glob to return no error on nonmatching patterns
Michael Shields [Sat, 17 Sep 2011 03:30:54 +0000 (20:30 -0700)]
filepath: fix Glob to return no error on nonmatching patterns

filepath.Glob is documented to return nil if no files match
and an error only if the pattern is invalid.  This change
fixes it to work as documented and adds a regression test.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5040045

12 years agoCONTRIBUTORS: add googler Michael Shields
Rob Pike [Sat, 17 Sep 2011 03:30:17 +0000 (20:30 -0700)]
CONTRIBUTORS: add googler Michael Shields

R=golang-dev, dsymonds
CC=golang-dev, mshields
https://golang.org/cl/5042045

12 years agotest: match gccgo error messages for bug330.go.
Ian Lance Taylor [Sat, 17 Sep 2011 01:28:57 +0000 (18:28 -0700)]
test: match gccgo error messages for bug330.go.

bug330.go:11:6: error: expected numeric type
bug330.go:12:6: error: expected numeric type

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5031050

12 years agoreflect: fix comment
Robert Griesemer [Fri, 16 Sep 2011 22:07:13 +0000 (15:07 -0700)]
reflect: fix comment

R=r
CC=golang-dev
https://golang.org/cl/5039045

12 years agohttp/cgi: clean up environment.
Yasuhiro Matsumoto [Fri, 16 Sep 2011 17:36:54 +0000 (10:36 -0700)]
http/cgi: clean up environment.
clean up duplicate environment for CGI.
overriding former by latter.
On windows, When there are duplicated environments like following,

SCRIPT_FILENAME=c:/progra~1/php/php-cgi.exe
SCRIPT_FILENAME=/foo.php

CreateProcess use first entry.

If make cgi.Handle like following,

        cgih = cgi.Handler{
                Path: "c:/strawberry/perl/bin/perl.exe",
                Dir:  "c:/path/to/webroot",
                Root: "c:/path/to/webroot",
                Args: []string{"foo.php"},
                Env:  []string{"SCRIPT_FILENAME=foo.php"},
        }

http/cgi should behave "SCRIPT_FILENAME is foo.php".
But currently, http/cgi is set duplicate environment entries.
So, browser show binary dump of "php-cgi.exe" that is specified indented
SCRIPT_FILENAME in first entry.
This change clean up duplicates, and use latters.

R=golang-dev, bradfitz, bradfitz
CC=golang-dev
https://golang.org/cl/5010044

12 years agoexp/norm: reverting to using strings.Repeat, as it doesn't look like exp/regexp
Marcel van Lohuizen [Fri, 16 Sep 2011 09:28:53 +0000 (11:28 +0200)]
exp/norm: reverting to using strings.Repeat, as it doesn't look like exp/regexp
is going to support returning multiple matches for a single repeated group.

R=r, rsc, mpvl
CC=golang-dev
https://golang.org/cl/5014045

12 years agoexp/norm: changed trie to produce smaller tables.
Marcel van Lohuizen [Fri, 16 Sep 2011 09:27:05 +0000 (11:27 +0200)]
exp/norm: changed trie to produce smaller tables.
Trie now uses sparse block when this makes sense.

R=r, r
CC=golang-dev
https://golang.org/cl/5010043

12 years agoexp/template/html: type fixed point computation in template
Mike Samuel [Fri, 16 Sep 2011 07:34:26 +0000 (00:34 -0700)]
exp/template/html: type fixed point computation in template

I found a simple test case that does require doing the fixed point TODO
in computeOutCtx.

I found a way though to do this and simplify away the escapeRange
hackiness that was added in https://golang.org/cl/5012044/

R=nigeltao
CC=golang-dev
https://golang.org/cl/5015052

12 years agotag weekly.2011-09-16
Andrew Gerrand [Fri, 16 Sep 2011 07:23:31 +0000 (17:23 +1000)]
tag weekly.2011-09-16

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5004052

12 years agoweekly.2011-09-16 weekly.2011-09-16
Andrew Gerrand [Fri, 16 Sep 2011 07:18:36 +0000 (17:18 +1000)]
weekly.2011-09-16

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/5040042

12 years agonet: reuse channels during io
Alex Brainman [Fri, 16 Sep 2011 03:40:02 +0000 (13:40 +1000)]
net: reuse channels during io

R=golang-dev, bsiegert, rsc, hectorchu
CC=golang-dev
https://golang.org/cl/5016043

12 years agoexp/template/html: moved error docs out of package docs onto error codes
Mike Samuel [Fri, 16 Sep 2011 02:05:33 +0000 (19:05 -0700)]
exp/template/html: moved error docs out of package docs onto error codes

This replaces the errStr & errLine members of context with a single err
*Error, and introduces a number of const error codes, one per
escape-time failure mode, that can be separately documented.

The changes to the error documentation moved from doc.go to error.go
are cosmetic.

R=r, nigeltao
CC=golang-dev
https://golang.org/cl/5026041

12 years agogodoc: remove dependency of syscall
Robert Griesemer [Thu, 15 Sep 2011 23:47:01 +0000 (16:47 -0700)]
godoc: remove dependency of syscall

On app-engine, we cannot import syscall.
The respective constants are already defined
elsewhere for the same reason.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/5036042

12 years agogodoc: use new index/suffixarray serialization code
Robert Griesemer [Thu, 15 Sep 2011 23:21:42 +0000 (16:21 -0700)]
godoc: use new index/suffixarray serialization code

When saving/restoring the fulltext index, the entire
respective suffixarray is now saved/restored (as opposed
to the indexed data only, and the suffixarray recreated).
This saves significant start-up time for large indexes,
at the cost of significantly larger index files.

R=r
CC=golang-dev
https://golang.org/cl/5037043

12 years agoindex/suffixarray: support for serialization
Robert Griesemer [Thu, 15 Sep 2011 23:21:21 +0000 (16:21 -0700)]
index/suffixarray: support for serialization

R=r
CC=golang-dev
https://golang.org/cl/5040041

12 years agotextproto: parse RFC 959 multiline responses correctly
Brad Fitzpatrick [Thu, 15 Sep 2011 21:29:59 +0000 (14:29 -0700)]
textproto: parse RFC 959 multiline responses correctly

Fixes #2218

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5037041

12 years agohttp: MaxBytesReader doc cleanups
Brad Fitzpatrick [Thu, 15 Sep 2011 21:26:22 +0000 (14:26 -0700)]
http: MaxBytesReader doc cleanups

Comments from rsc after 4921049 was submitted.

R=rsc
CC=golang-dev
https://golang.org/cl/5034042

12 years agohttp: document that Response.Body is non-nil
Brad Fitzpatrick [Thu, 15 Sep 2011 21:09:53 +0000 (14:09 -0700)]
http: document that Response.Body is non-nil

Fixes #2208

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5011051

12 years agoflag: make zero FlagSet useful
Russ Cox [Thu, 15 Sep 2011 21:04:51 +0000 (17:04 -0400)]
flag: make zero FlagSet useful

This makes it possible to use a FlagSet as a
field in a larger struct.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5036041

12 years agogodoc: use go/build to find files in a package
Russ Cox [Thu, 15 Sep 2011 20:49:06 +0000 (16:49 -0400)]
godoc: use go/build to find files in a package

Fixes #1156.
Fixes #2172.

R=gri
CC=golang-dev
https://golang.org/cl/5015044

12 years agobuild: add build comments to core packages
Russ Cox [Thu, 15 Sep 2011 20:48:57 +0000 (16:48 -0400)]
build: add build comments to core packages

The go/build package already recognizes
system-specific file names like

        mycode_darwin.go
        mycode_darwin_386.go
        mycode_386.s

However, it is also common to write files that
apply to multiple architectures, so a recent CL added
to go/build the ability to process comments
listing a set of conditions for building.  For example:

        // +build darwin freebsd openbsd/386

says that this file should be compiled only on
OS X, FreeBSD, or 32-bit x86 OpenBSD systems.

These conventions are not yet documented
(hence this long CL description).

This CL adds build comments to the multi-system
files in the core library, a step toward making it
possible to use go/build to build them.

With this change go/build can handle crypto/rand,
exec, net, path/filepath, os/user, and time.

os and syscall need additional adjustments.

R=golang-dev, r, gri, r, gustavo
CC=golang-dev
https://golang.org/cl/5011046

12 years agogo/build: change //build to // +build
Russ Cox [Thu, 15 Sep 2011 20:48:21 +0000 (16:48 -0400)]
go/build: change //build to // +build

New rules as discussed on CL 5011046.
Also apply to C and assembly files, not just Go files.

R=r, rogpeppe
CC=golang-dev
https://golang.org/cl/5015051

12 years agohttp/cgi: add openbsd environment configuration
Brad Fitzpatrick [Thu, 15 Sep 2011 19:41:00 +0000 (12:41 -0700)]
http/cgi: add openbsd environment configuration

R=iant, iant
CC=golang-dev
https://golang.org/cl/5016051

12 years agohttp: fix WriteProxy documentation
Brad Fitzpatrick [Thu, 15 Sep 2011 17:28:55 +0000 (10:28 -0700)]
http: fix WriteProxy documentation

Fixes #2258

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5016048

12 years agogo/build: fix build (revert test changes)
Russ Cox [Thu, 15 Sep 2011 16:34:34 +0000 (12:34 -0400)]
go/build: fix build (revert test changes)

R=adg
TBR=adg
CC=golang-dev
https://golang.org/cl/5024046

12 years agogo/build: handle cgo, //build comments
Russ Cox [Thu, 15 Sep 2011 16:11:41 +0000 (12:11 -0400)]
go/build: handle cgo, //build comments

R=adg
CC=golang-dev
https://golang.org/cl/5018044

12 years agoexp/template/html: pre-sanitized content
Mike Samuel [Thu, 15 Sep 2011 15:51:55 +0000 (08:51 -0700)]
exp/template/html: pre-sanitized content

Not all content is plain text.  Sometimes content comes from a trusted
source, such as another template invocation, an HTML tag whitelister,
etc.

Template authors can deal with over-escaping in two ways.

1) They can encapsulate known-safe content via
   type HTML, type CSS, type URL, and friends in content.go.
2) If they know that the for a particular action never needs escaping
   then they can add |noescape to the pipeline.
   {{.KnownSafeContent | noescape}}
   which will prevent any escaping directives from being added.

This CL defines string type aliases: HTML, CSS, JS, URI, ...
It then modifies stringify to unpack the content type.
Finally it modifies the escaping functions to use the content type and
decline to escape content that does not require it.

There are minor changes to escapeAction and helpers to treat as
equivalent explicit escaping directives such as "html" and "urlquery"
and the escaping directives defined in the contextual autoescape module
and to recognize the special "noescape" directive.

The html escaping functions are rearranged.  Instead of having one
escaping function used in each {{.}} in

    {{.}} : <textarea title="{{.}}">{{.}}</textarea>

a slightly different escaping function is used for each.
When {{.}} binds to a pre-sanitized string of HTML

    `one < <i>two</i> &amp; two < "3"`

we produces something like

     one < <i>two</i> &amp; two < "3" :
     <textarea title="one &lt; two &amp; two &lt; &#34;3&#34;">
       one &lt; &lt;i&gt;two&lt;/i&gt; &amp; two &lt; "3"
     </textarea>

Although escaping is not required in <textarea> normally, if the
substring </textarea> is injected, then it breaks, so we normalize
special characters in RCDATA and do the same to preserve attribute
boundaries.  We also strip tags since developers never intend
typed HTML injected in an attribute to contain tags escaped, but
do occasionally confuse pre-escaped HTML with HTML from a
tag-whitelister.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/4962067

12 years agodoc: release.r60.1
Andrew Gerrand [Thu, 15 Sep 2011 09:26:12 +0000 (19:26 +1000)]
doc: release.r60.1

R=r
CC=golang-dev
https://golang.org/cl/5002041

12 years agogodoc: support for complete index serialization
Robert Griesemer [Thu, 15 Sep 2011 03:46:03 +0000 (20:46 -0700)]
godoc: support for complete index serialization

- now fulltext index information is saved/restored
- minor updates to appinit.go

R=rsc
CC=golang-dev
https://golang.org/cl/5024043

12 years agogo/token: support to serialize file sets
Robert Griesemer [Thu, 15 Sep 2011 03:45:45 +0000 (20:45 -0700)]
go/token: support to serialize file sets

R=rsc
CC=golang-dev
https://golang.org/cl/5024042

12 years agoexp/template/html: render templates unusable when escaping fails
Mike Samuel [Thu, 15 Sep 2011 03:40:50 +0000 (20:40 -0700)]
exp/template/html: render templates unusable when escaping fails

This moots a caveat in the proposed package documentation by
rendering useless any template that could not be escaped.

From https://golang.org/cl/4969078/
> If EscapeSet returns an error, do not Execute the set; it is not
> safe against injection.
r: [but isn't the returned set nil? i guess you don't overwrite the
r: original if there's a problem, but i think you're in your rights to
r: do so]

R=r
CC=golang-dev
https://golang.org/cl/5020043

12 years agoruntime: eliminate handle churn when churning channels on Windows
Hector Chu [Thu, 15 Sep 2011 00:23:21 +0000 (20:23 -0400)]
runtime: eliminate handle churn when churning channels on Windows

The Windows implementation of the net package churns through a couple of channels for every read/write operation.  This translates into a lot of time spent in the kernel creating and deleting event objects.

R=rsc, dvyukov, alex.brainman, jp
CC=golang-dev
https://golang.org/cl/4997044

12 years agodebug/elf: permit another case of SHT_NOBITS section overlap in test
Ian Lance Taylor [Wed, 14 Sep 2011 22:33:37 +0000 (15:33 -0700)]
debug/elf: permit another case of SHT_NOBITS section overlap in test

Lets test pass when using gccgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5018046

12 years agojson: if a field's tag is "-", never encode it.
David Symonds [Wed, 14 Sep 2011 22:09:43 +0000 (08:09 +1000)]
json: if a field's tag is "-", never encode it.

R=adg, r, edsrzf, rsc, r
CC=golang-dev
https://golang.org/cl/4962052

12 years agoexp/template/html: flesh out package documentation.
Mike Samuel [Wed, 14 Sep 2011 21:21:20 +0000 (14:21 -0700)]
exp/template/html: flesh out package documentation.

R=nigeltao, r
CC=golang-dev
https://golang.org/cl/4969078

12 years agosrc: fix a couple of govet-discovered errors.
Rob Pike [Wed, 14 Sep 2011 20:29:31 +0000 (13:29 -0700)]
src: fix a couple of govet-discovered errors.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5021042

12 years agocrypto/tls: support SSLv3
Adam Langley [Wed, 14 Sep 2011 19:32:19 +0000 (15:32 -0400)]
crypto/tls: support SSLv3

It would be nice not to have to support this since all the clients
that we care about support TLSv1 by now. However, due to buggy
implementations of SSLv3 on the Internet which can't do version
negotiation correctly, browsers will sometimes switch to SSLv3. Since
there's no good way for a browser tell a network problem from a buggy
server, this downgrade can occur even if the server in question is
actually working correctly.

So we need to support SSLv3 for robustness :(

Fixes #1703.

R=bradfitz
CC=golang-dev
https://golang.org/cl/5018045

12 years agoexp/template/html: check that modified nodes are not shared by templates
Mike Samuel [Wed, 14 Sep 2011 18:52:03 +0000 (11:52 -0700)]
exp/template/html: check that modified nodes are not shared by templates

R=nigeltao
CC=golang-dev
https://golang.org/cl/5012044

12 years agopath/filepath: document that Walk sorts its output
Rob Pike [Wed, 14 Sep 2011 18:18:43 +0000 (11:18 -0700)]
path/filepath: document that Walk sorts its output

R=golang-dev, cw
CC=golang-dev
https://golang.org/cl/5004045

12 years agoexp/norm: added normregtest to .hgignore.
Marcel van Lohuizen [Wed, 14 Sep 2011 18:03:21 +0000 (20:03 +0200)]
exp/norm: added normregtest to .hgignore.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5009045

12 years agotest: Add test for inheriting private method from anonymous field.
Ian Lance Taylor [Wed, 14 Sep 2011 17:31:51 +0000 (10:31 -0700)]
test: Add test for inheriting private method from anonymous field.

The spec says that all methods are inherited from an anonymous
field.  There is no exception for non-exported methods.

This is related to issue 1536.

R=rsc
CC=golang-dev
https://golang.org/cl/5012043

12 years agogo/printer: use panic/defer instead of goroutine
Robert Griesemer [Wed, 14 Sep 2011 15:49:21 +0000 (08:49 -0700)]
go/printer: use panic/defer instead of goroutine
for handling errors

Fixes #2249.

R=rsc
CC=golang-dev
https://golang.org/cl/4952071

12 years agogofmt: add else test
Russ Cox [Wed, 14 Sep 2011 15:29:18 +0000 (11:29 -0400)]
gofmt: add else test

R=gri
CC=golang-dev
https://golang.org/cl/4978065

12 years agowebsocket: rename websocket.WebSocketAddr to *websocket.Addr.
Russ Cox [Wed, 14 Sep 2011 15:29:11 +0000 (11:29 -0400)]
websocket: rename websocket.WebSocketAddr to *websocket.Addr.

R=ukai
CC=golang-dev
https://golang.org/cl/4999043

12 years agoruntime: track HeapIdle
Russ Cox [Wed, 14 Sep 2011 15:29:01 +0000 (11:29 -0400)]
runtime: track HeapIdle

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4995045

12 years agoimage/jpeg: fix build
Mikio Hara [Wed, 14 Sep 2011 15:14:03 +0000 (11:14 -0400)]
image/jpeg: fix build

R=golang-dev
CC=golang-dev
https://golang.org/cl/5020045