mirror of
https://github.com/golang/go
synced 2024-11-22 04:34:39 -07:00
go/doc: use correct escaper for URL
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
This commit is contained in:
parent
218afb8fbd
commit
b0729cdfe5
@ -8,7 +8,6 @@ package doc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"http" // for URLEscape
|
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -227,7 +226,7 @@ func emphasize(w io.Writer, line []byte, words map[string]string, nice bool) {
|
|||||||
// write match
|
// write match
|
||||||
if len(url) > 0 {
|
if len(url) > 0 {
|
||||||
w.Write(html_a)
|
w.Write(html_a)
|
||||||
w.Write([]byte(http.URLEscape(url)))
|
template.HTMLEscape(w, []byte(url))
|
||||||
w.Write(html_aq)
|
w.Write(html_aq)
|
||||||
}
|
}
|
||||||
if italics {
|
if italics {
|
||||||
|
Loading…
Reference in New Issue
Block a user