1. 15 Sep, 2011 9 commits
    • Brad Fitzpatrick's avatar
      http: fix WriteProxy documentation · 7233dcde
      Brad Fitzpatrick authored
      Fixes #2258
      
      R=golang-dev, rsc
      CC=golang-dev
      https://golang.org/cl/5016048
      7233dcde
    • Russ Cox's avatar
      go/build: fix build (revert test changes) · 6430f46e
      Russ Cox authored
      R=adg
      TBR=adg
      CC=golang-dev
      https://golang.org/cl/5024046
      6430f46e
    • Russ Cox's avatar
      go/build: handle cgo, //build comments · 17bebd3c
      Russ Cox authored
      R=adg
      CC=golang-dev
      https://golang.org/cl/5018044
      17bebd3c
    • Mike Samuel's avatar
      exp/template/html: pre-sanitized content · ce008f8c
      Mike Samuel authored
      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
      ce008f8c
    • Andrew Gerrand's avatar
      doc: release.r60.1 · f41ab6c7
      Andrew Gerrand authored
      R=r
      CC=golang-dev
      https://golang.org/cl/5002041
      f41ab6c7
    • Robert Griesemer's avatar
      godoc: support for complete index serialization · d76c4a52
      Robert Griesemer authored
      - now fulltext index information is saved/restored
      - minor updates to appinit.go
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/5024043
      d76c4a52
    • Robert Griesemer's avatar
      go/token: support to serialize file sets · 957fd575
      Robert Griesemer authored
      R=rsc
      CC=golang-dev
      https://golang.org/cl/5024042
      957fd575
    • Mike Samuel's avatar
      exp/template/html: render templates unusable when escaping fails · 3eb41fbe
      Mike Samuel authored
      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
      3eb41fbe
    • Hector Chu's avatar
      runtime: eliminate handle churn when churning channels on Windows · 5c303259
      Hector Chu authored
      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
      5c303259
  2. 14 Sep, 2011 20 commits
  3. 13 Sep, 2011 7 commits
    • Mike Samuel's avatar
      exp/template/html: escape {{template}} calls and sets of templates · 4c6454ae
      Mike Samuel authored
      This adds support for {{template "callee"}} calls.
      It recognizes that calls can appear in many contexts.
      
      {{if .ImageURL}}
          <img src="{{.ImageURL}}" alt="{{template "description"}}">
      {{else}}
          <p>{{template "description"}}</p>
      {{end}}
      
      calls a template in two different contexts, first in an HTML attribute
      context, and second in an HTML text context.
      
      Those two contexts aren't very different, but when linking text
      to search terms, the escaping context can be materially different:
      
      <a href="/search?q={{template "tags"}}">{{template "tags"}}</a>
      
      This adds API:
      EscapeSet(*template.Set, names ...string) os.Error
      
      takes a set of templates and the names of those which might be called
      in the default context as starting points.
      
      It changes the escape* functions to be methods of an object which
      maintains a conceptual mapping of
      (template names*input context) -> output context.
      
      The actual mapping uses as key a mangled name which combines the
      template name with the input context.
      
      The mangled name when the input context is the default context is the
      same as the unmangled name.
      
      When a template is called in multiple contexts, we clone the template.
      
      {{define "tagLink"}}
        <a href="/search?q={{template "tags"}}">{{template "tags"}}</a>
      {{end}}
      {{define "tags"}}
        {{range .Tags}}{{.}},{{end}}
      {{end}}
      
      given []string{ "foo", "O'Reilly", "bar" } produces
      
        <a href="/search?q=foo,O%27Reilly,bar">foo,O&#39;Reilly,bar</a>
      
      This involves rewriting the above to something like
      
      {{define "tagLink"}}
        <a href="/search?q={{template "tags$1"}}">{{template "tags"}}</a>
      {{end}}
      {{define "tags"}}
        {{range .Tags}}{{. | html}},{{end}}
      {{end}}
      {{define "tags$1"}}
        {{range .Tags}}{{. | urlquery}},{{end}}
      {{end}}
      
      clone.go provides a mechanism for cloning template "tags" to produce
      "tags$1".
      
      changes to escape.go implement the new API and context propagation
      around the call graph.
      
      context.go includes minor changes to support name mangling and
      context_test.go tests those.
      
      js.go contains a bug-fix.
      
      R=nigeltao, r
      CC=golang-dev
      https://golang.org/cl/4969072
      4c6454ae
    • Ian Lance Taylor's avatar
      http: Alphabetize imports. · 9377b288
      Ian Lance Taylor authored
      R=golang-dev, bradfitz
      CC=golang-dev
      https://golang.org/cl/5002043
      9377b288
    • Ian Lance Taylor's avatar
      os: Fix comment in generated signal_unix.go file. · 096f3a29
      Ian Lance Taylor authored
      R=golang-dev, bradfitz
      CC=golang-dev
      https://golang.org/cl/5013042
      096f3a29
    • Marcel van Lohuizen's avatar
    • Nigel Tao's avatar
      net: add a LookupTXT function. · 40d85fb0
      Nigel Tao authored
      This CL only supports Unix, not Plan 9 or Windows.
      
      R=rsc
      CC=golang-dev
      https://golang.org/cl/4996048
      40d85fb0
    • Alex Brainman's avatar
      time: another attempt to fix windows build · cd269b0c
      Alex Brainman authored
      R=bradfitz
      CC=golang-dev
      https://golang.org/cl/4967067
      cd269b0c
    • Brad Fitzpatrick's avatar
      time: fix Windows build after ceeedb519c4a · 29d5d9a5
      Brad Fitzpatrick authored
      R=golang-dev, r
      CC=golang-dev
      https://golang.org/cl/4983060
      29d5d9a5
  4. 12 Sep, 2011 4 commits
    • Mike Samuel's avatar
      exp/template/html: tolerate '/' ambiguity in JS when it doesn't matter. · 0432a23c
      Mike Samuel authored
      Often, division/regexp ambiguity doesn't matter in JS because the next
      token is not a slash.
      
      For example, in
      
        <script>var global{{if .InitVal}} = {{.InitVal}}{{end}}</script>
      
      When there is an initial value, the {{if}} ends with jsCtxDivOp
      since a '/' following {{.InitVal}} would be a division operator.
      When there is none, the empty {{else}} branch ends with jsCtxRegexp
      since a '/' would start a regular expression.  A '/' could result
      in a valid program if it were on a new line to allow semicolon
      insertion to terminate the VarDeclaration.
      
      There is no '/' though, so we can ignore the ambiguity.
      
      There are cases where a missing semi can result in ambiguity that
      we should report.
      
        <script>
        {{if .X}}var x = {{.X}}{{end}}
        /...{{.Y}}
        </script>
      
      where ... could be /foo/.test(bar) or /divisor.  Disambiguating in
      this case is hard and is required to sanitize {{.Y}}.
      
      Note, that in the case where there is a '/' in the script tail but it
      is not followed by any interpolation, we already don't care.  So we
      are already tolerant of
      
      <script>{{if .X}}var x = {{.X}}{{end}}/a-bunch-of-text</script>
      
      because tJS checks for </script> before looking in /a-bunch-of-text.
      
      This CL
      - Adds a jsCtx value: jsCtxUnknown
      - Changes joinContext to join contexts that only differ by jsCtx.
      - Changes tJS to return an error when a '/' is seen in jsCtxUnknown.
      - Adds tests for both the happy and sad cases.
      
      R=nigeltao
      CC=golang-dev
      https://golang.org/cl/4956077
      0432a23c
    • Mike Samuel's avatar
      exp/template/html: fix bug /*/ is not a full JS block comment. · 80a5ddbd
      Mike Samuel authored
      Similar tests for CSS already catch this problem in tCSS.
      
      R=nigeltao
      CC=golang-dev
      https://golang.org/cl/4967065
      80a5ddbd
    • Russ Cox's avatar
      crypto/tls: handle non-TLS more robustly · 3b189d8f
      Russ Cox authored
      Fixes #2253.
      
      R=agl
      CC=golang-dev
      https://golang.org/cl/4960066
      3b189d8f
    • Russ Cox's avatar
      gc: clean up if grammar · 9fc68739
      Russ Cox authored
      Fixes #2248.
      
      R=ken2
      CC=golang-dev
      https://golang.org/cl/4978064
      9fc68739