Replacement for CL 184084; originally by Roger Peppe (rogpeppe@gmail.com).
R=rsc
CC=golang-dev, rog
https://golang.org/cl/189059
</tr>
{.repeated section @}
<tr>
- <td align="left"><a href="{Name|html}{@|dir/}">{Name|html}{@|dir/}</a></td>
+ <td align="left"><a href="{Name|html-esc}{@|dir/}">{Name|html}{@|dir/}</a></td>
<td></td>
<td align="right">{Size|html}</td>
<td></td>
<li class="blank"> </li>
<li class="navhead">Go code search</li>
<form method="GET" action="/search" class="search">
- <input type="search" name="q" value="{Query|html}" size="25" style="width:80%; max-width:200px" />
+ <input type="search" name="q" value="{Query|html-esc}" size="25" style="width:80%; max-width:200px" />
<input type="submit" value="Go" />
</form>
<h4>Package files</h4>
<span style="font-size:90%">
{.repeated section @}
- <a href="/{FilePath|html}/{@|html}">{@|html}</a>
+ <a href="/{FilePath|html-esc}/{@|html-esc}">{@|html}</a>
{.end}
</span>
</p>
{.end}
{.section Funcs}
{.repeated section @}
- <h2 id="{Name|html}">func <a href="{Decl|link}">{Name|html}</a></h2>
+ <h2 id="{Name|html-esc}">func <a href="{Decl|link}">{Name|html}</a></h2>
<p><code>{Decl|html}</code></p>
{Doc|html-comment}
{.end}
{.end}
{.section Types}
{.repeated section @}
- <h2 id="{Type.Name|html}">type <a href="{Decl|link}">{Type.Name|html}</a></h2>
+ <h2 id="{Type.Name|html-esc}">type <a href="{Decl|link}">{Type.Name|html}</a></h2>
{Doc|html-comment}
<p><pre>{Decl|html}</pre></p>
{.repeated section Consts}
<pre>{Decl|html}</pre>
{.end}
{.repeated section Factories}
- <h3 id="{Type.Name|html}.{Name|html}">func <a href="{Decl|link}">{Name|html}</a></h3>
+ <h3 id="{Type.Name|html-esc}.{Name|html-esc}">func <a href="{Decl|link}">{Name|html}</a></h3>
<p><code>{Decl|html}</code></p>
{Doc|html-comment}
{.end}
{.repeated section Methods}
- <h3 id="{Type.Name|html}.{Name|html}">func ({Recv|html}) <a href="{Decl|link}">{Name|html}</a></h3>
+ <h3 id="{Type.Name|html-esc}.{Name|html-esc}">func ({Recv|html}) <a href="{Decl|link}">{Name|html}</a></h3>
<p><code>{Decl|html}</code></p>
{Doc|html-comment}
{.end}
<p>
<table class="layout">
<tr>
- <th align="left" colspan="{MaxHeight|html}">Name</th>
+ <th align="left" colspan="{MaxHeight|html-esc}">Name</th>
<td width="25"> </td>
<th align="left">Synopsis</th>
</tr>
{.repeated section List}
<tr>
{Depth|padding}
- <td align="left" colspan="{Height|html}"><a href="{Path|html}">{Name|html}<a></td>
+ <td align="left" colspan="{Height|html-esc}"><a href="{Path|html-esc}">{Name|html}<a></td>
<td></td>
<td align="left">{Synopsis|html}</td>
</tr>
<p>
<span class="alert" style="font-size:120%">Did you mean: </span>
{.repeated section Alts}
- <a href="search?q={@|html}" style="font-size:120%">{@|html}</a>
+ <a href="search?q={@|html-esc}" style="font-size:120%">{@|html}</a>
{.end}
</p>
{.end}
{.repeated section Files}
{.repeated section Groups}
{.repeated section Infos}
- <a href="{File.Path|html}?h={Query|html}#L{@|infoLine}">{File.Path|html}:{@|infoLine}</a>
+ <a href="{File.Path|html-esc}?h={Query|html-esc}#L{@|infoLine}">{File.Path|html}:{@|infoLine}</a>
<pre>{@|infoSnippet}</pre>
{.end}
{.end}
{.repeated section @}
<h3 id="Local_{Pak.Path|path}">package <a href="{Pak.Path|path}">{Pak.Name|html}</a></h3>
{.repeated section Files}
- <a href="{File.Path|html}?h={Query|html}">{File.Path|html}</a>
+ <a href="{File.Path|html-esc}?h={Query|html-esc}">{File.Path|html}</a>
<table class="layout">
{.repeated section Groups}
<tr>
<td align="left" width="4"></td>
<td>
{.repeated section Infos}
- <a href="{File.Path|html}?h={Query|html}#L{@|infoLine}">{@|infoLine}</a>
+ <a href="{File.Path|html-esc}?h={Query|html-esc}#L{@|infoLine}">{@|infoLine}</a>
{.end}
</td>
</tr>
}
+// Template formatter for "html-esc" format.
+func htmlEscFmt(w io.Writer, x interface{}, format string) {
+ var buf bytes.Buffer
+ writeAny(&buf, x, false)
+ template.HTMLEscape(w, buf.Bytes())
+}
+
+
// Template formatter for "html-comment" format.
func htmlCommentFmt(w io.Writer, x interface{}, format string) {
var buf bytes.Buffer
var fmap = template.FormatterMap{
"": textFmt,
"html": htmlFmt,
+ "html-esc": htmlEscFmt,
"html-comment": htmlCommentFmt,
"path": pathFmt,
"link": linkFmt,