@@ -72,7 +72,8 @@ func funcClass(c *Call) template.HTML {
7272 if c .Func .IsExported {
7373 s += " Exported"
7474 }
75- return template .HTML ("Func" + s )
75+ /* #nosec G203 */
76+ return template .HTML ("Func" ) + template .HTML (template .HTMLEscapeString (s ))
7677}
7778
7879func minus (i , j int ) int {
@@ -107,23 +108,24 @@ func pkgURL(c *Call) template.URL {
107108 }
108109 }
109110 if c .Func .IsExported {
110- return template . URL ( url + ip + "#" + symbol (& c .Func ) )
111+ return url + ip + template . URL ( "#" ) + symbol (& c .Func )
111112 }
112- return template . URL ( url + ip )
113+ return url + ip
113114}
114115
115116// srcURL returns an URL to the sources.
116117//
117118// TODO(maruel): Support custom local godoc server as it serves files too.
118119func srcURL (c * Call ) template.URL {
119120 url , _ := getSrcBranchURL (c )
120- return template . URL ( url )
121+ return url
121122}
122123
123124func escape (s string ) template.URL {
124125 // That's the only way I found to get the kind of escaping I wanted, where
125126 // '/' is not escaped.
126127 u := url.URL {Path : s }
128+ /* #nosec G203 */
127129 return template .URL (u .EscapedPath ())
128130}
129131
@@ -140,6 +142,7 @@ func getSrcBranchURL(c *Call) (template.URL, template.URL) {
140142 ver = ver [len (devel ) : len (devel )+ 10 ]
141143 }
142144 tag = url .QueryEscape (ver )
145+ /* #nosec G203 */
143146 return template .URL (fmt .Sprintf ("https://github.com/golang/go/blob/%s/src/%s#L%d" , tag , escape (c .RelSrcPath ), c .Line )), template .URL (tag )
144147 }
145148 // TODO(maruel): Leverage Location.
@@ -156,6 +159,7 @@ func getSrcBranchURL(c *Call) (template.URL, template.URL) {
156159 if parts := strings .SplitN (rest , "/" , 3 ); len (parts ) == 3 {
157160 p , srcTag , tag := splitTag (parts [1 ])
158161 url := fmt .Sprintf ("https://github.com/%s/%s/blob/%s/%s#L%d" , escape (parts [0 ]), p , srcTag , escape (parts [2 ]), c .Line )
162+ /* #nosec G203 */
159163 return template .URL (url ), tag
160164 }
161165 log .Printf ("problematic github.com URL: %q" , rel )
@@ -168,6 +172,7 @@ func getSrcBranchURL(c *Call) (template.URL, template.URL) {
168172 // The source of truth is are actually go.googlesource.com, but
169173 // github.com has nicer syntax highlighting.
170174 url := fmt .Sprintf ("https://github.com/golang/%s/blob/%s/%s#L%d" , p , srcTag , escape (parts [2 ]), c .Line )
175+ /* #nosec G203 */
171176 return template .URL (url ), tag
172177 }
173178 log .Printf ("problematic golang.org URL: %q" , rel )
@@ -185,9 +190,11 @@ func getSrcBranchURL(c *Call) (template.URL, template.URL) {
185190 }
186191
187192 if c .LocalSrcPath != "" {
193+ /* #nosec G203 */
188194 return template .URL ("file:///" + escape (c .LocalSrcPath )), template .URL (tag )
189195 }
190196 if c .RemoteSrcPath != "" {
197+ /* #nosec G203 */
191198 return template .URL ("file:///" + escape (c .RemoteSrcPath )), template .URL (tag )
192199 }
193200 return "" , ""
@@ -219,6 +226,7 @@ func splitTag(s string) (string, string, template.URL) {
219226 if m := reVersion .FindStringSubmatch (tag ); len (m ) != 0 {
220227 srcTag = m [1 ]
221228 }
229+ /* #nosec G203 */
222230 return s [:i ], url .QueryEscape (srcTag ), template .URL (url .QueryEscape (tag ))
223231}
224232
@@ -233,5 +241,6 @@ func symbol(f *Func) template.URL {
233241 // Transform the method form.
234242 s = reMethodSymbol .ReplaceAllString (s , "$1$2" )
235243 }
244+ /* #nosec G203 */
236245 return template .URL (url .QueryEscape (s ))
237246}
0 commit comments