]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: use correct escaper for URL
authorRuss Cox <rsc@golang.org>
Wed, 25 Aug 2010 15:00:38 +0000 (11:00 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 25 Aug 2010 15:00:38 +0000 (11:00 -0400)
Despite the name, URL escaping is for a small subpiece of the URL only.
This particular URL is being emitted in an <a href=""> tag and in that
context it should be HTML escaped, not URL escaped.

In addition to fixing a bug, this change cuts a dependency chain
from go/doc to net, clearing the way for use of cgo
(which imports go/doc) during the compilation of package net.

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

src/pkg/go/doc/comment.go

index cd985d8a7f85a84553c4bf16d268e658cf467b23..583b763eaf6d0ca4b251b643d5d4294dc7c296c5 100644 (file)
@@ -8,7 +8,6 @@ package doc
 
 import (
        "go/ast"
-       "http" // for URLEscape
        "io"
        "regexp"
        "strings"
@@ -227,7 +226,7 @@ func emphasize(w io.Writer, line []byte, words map[string]string, nice bool) {
                // write match
                if len(url) > 0 {
                        w.Write(html_a)
-                       w.Write([]byte(http.URLEscape(url)))
+                       template.HTMLEscape(w, []byte(url))
                        w.Write(html_aq)
                }
                if italics {