1. 15 Sep, 2011 5 commits
  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 8 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
    • Russ Cox's avatar
      gofmt: accept program fragments on standard input · 48e9c771
      Russ Cox authored
      This makes it possible to grab a block of code
      in an editor and pipe it through gofmt, instead of
      having to pipe in the entire file.
      
      R=gri
      CC=golang-dev
      https://golang.org/cl/4973074
      48e9c771
    • Robert Griesemer's avatar
      godoc, suffixarray: switch to exp/regexp · 7944bbf2
      Robert Griesemer authored
      R=rsc
      CC=golang-dev
      https://golang.org/cl/4983058
      7944bbf2
    • Gustavo Niemeyer's avatar
      path/filepath: fix Visitor doc · 817da665
      Gustavo Niemeyer authored
      The path is not in fact relative to the root, but
      joined to it.
      
      R=golang-dev, adg, rsc, gustavo
      CC=golang-dev
      https://golang.org/cl/4977059
      817da665
    • Rob Pike's avatar
      time: make Weekday a method. · 7d43b842
      Rob Pike authored
      Weekday is redundant information for a Time structure.
      When parsing a time with a weekday specified, it can create an
      incorrect Time value.
      When parsing a time without a weekday specified, people
      expect the weekday to be set.
      Fix all three problems by computing the weekday on demand.
      
      This is hard to gofix, since we must change the type of the node.
      Since uses are rare and existing code will be caught by the compiler,
      there is no gofix module here.
      
      Fixes #2245.
      
      R=golang-dev, bradfitz, rsc
      CC=golang-dev
      https://golang.org/cl/4974077
      7d43b842