Commit 16b95507 authored by Shenghou Ma's avatar Shenghou Ma

html/template: fix broken links

Fixes #7562.

LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/81190044
parent 15bc7ab9
...@@ -90,7 +90,7 @@ var attrTypeMap = map[string]contentType{ ...@@ -90,7 +90,7 @@ var attrTypeMap = map[string]contentType{
"name": contentTypePlain, "name": contentTypePlain,
"novalidate": contentTypeUnsafe, "novalidate": contentTypeUnsafe,
// Skip handler names from // Skip handler names from
// http://www.w3.org/TR/html5/Overview.html#event-handlers-on-elements-document-objects-and-window-objects // http://www.w3.org/TR/html5/webappapis.html#event-handlers-on-elements,-document-objects,-and-window-objects
// since we have special handling in attrType. // since we have special handling in attrType.
"open": contentTypePlain, "open": contentTypePlain,
"optimum": contentTypePlain, "optimum": contentTypePlain,
...@@ -160,7 +160,7 @@ func attrType(name string) contentType { ...@@ -160,7 +160,7 @@ func attrType(name string) contentType {
// Heuristics to prevent "javascript:..." injection in custom // Heuristics to prevent "javascript:..." injection in custom
// data attributes and custom attributes like g:tweetUrl. // data attributes and custom attributes like g:tweetUrl.
// http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes: // http://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes
// "Custom data attributes are intended to store custom data // "Custom data attributes are intended to store custom data
// private to the page or application, for which there are no // private to the page or application, for which there are no
// more appropriate attributes or elements." // more appropriate attributes or elements."
......
...@@ -16,7 +16,8 @@ type ( ...@@ -16,7 +16,8 @@ type (
// 2. The CSS3 rule production, such as `a[href=~"https:"].foo#bar`. // 2. The CSS3 rule production, such as `a[href=~"https:"].foo#bar`.
// 3. CSS3 declaration productions, such as `color: red; margin: 2px`. // 3. CSS3 declaration productions, such as `color: red; margin: 2px`.
// 4. The CSS3 value production, such as `rgba(0, 0, 255, 127)`. // 4. The CSS3 value production, such as `rgba(0, 0, 255, 127)`.
// See http://www.w3.org/TR/css3-syntax/#style // See http://www.w3.org/TR/css3-syntax/#parsing and
// https://web.archive.org/web/20090211114933/http://w3.org/TR/css3-syntax#style
CSS string CSS string
// HTML encapsulates a known safe HTML document fragment. // HTML encapsulates a known safe HTML document fragment.
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
// //
// The zero value of type context is the start context for a template that // The zero value of type context is the start context for a template that
// produces an HTML fragment as defined at // produces an HTML fragment as defined at
// http://www.w3.org/TR/html5/the-end.html#parsing-html-fragments // http://www.w3.org/TR/html5/syntax.html#the-end
// where the context element is null. // where the context element is null.
type context struct { type context struct {
state state state state
...@@ -96,7 +96,7 @@ const ( ...@@ -96,7 +96,7 @@ const (
// stateHTMLCmt occurs inside an <!-- HTML comment -->. // stateHTMLCmt occurs inside an <!-- HTML comment -->.
stateHTMLCmt stateHTMLCmt
// stateRCDATA occurs inside an RCDATA element (<textarea> or <title>) // stateRCDATA occurs inside an RCDATA element (<textarea> or <title>)
// as described at http://dev.w3.org/html5/spec/syntax.html#elements-0 // as described at http://www.w3.org/TR/html5/syntax.html#elements-0
stateRCDATA stateRCDATA
// stateAttr occurs inside an HTML attribute whose content is text. // stateAttr occurs inside an HTML attribute whose content is text.
stateAttr stateAttr
......
...@@ -664,7 +664,7 @@ func contextAfterText(c context, s []byte) (context, int) { ...@@ -664,7 +664,7 @@ func contextAfterText(c context, s []byte) (context, int) {
i = len(s) i = len(s)
} }
if c.delim == delimSpaceOrTagEnd { if c.delim == delimSpaceOrTagEnd {
// http://www.w3.org/TR/html5/tokenization.html#attribute-value-unquoted-state // http://www.w3.org/TR/html5/syntax.html#attribute-value-(unquoted)-state
// lists the runes below as error characters. // lists the runes below as error characters.
// Error out because HTML parsers may differ on whether // Error out because HTML parsers may differ on whether
// "<a id= onclick=f(" ends inside id's or onclick's value, // "<a id= onclick=f(" ends inside id's or onclick's value,
......
...@@ -50,12 +50,12 @@ func htmlEscaper(args ...interface{}) string { ...@@ -50,12 +50,12 @@ func htmlEscaper(args ...interface{}) string {
// htmlReplacementTable contains the runes that need to be escaped // htmlReplacementTable contains the runes that need to be escaped
// inside a quoted attribute value or in a text node. // inside a quoted attribute value or in a text node.
var htmlReplacementTable = []string{ var htmlReplacementTable = []string{
// http://www.w3.org/TR/html5/tokenization.html#attribute-value-unquoted-state: " // http://www.w3.org/TR/html5/syntax.html#attribute-value-(unquoted)-state
// U+0000 NULL Parse error. Append a U+FFFD REPLACEMENT // U+0000 NULL Parse error. Append a U+FFFD REPLACEMENT
// CHARACTER character to the current attribute's value. // CHARACTER character to the current attribute's value.
// " // "
// and similarly // and similarly
// http://www.w3.org/TR/html5/tokenization.html#before-attribute-value-state // http://www.w3.org/TR/html5/syntax.html#before-attribute-value-state
0: "\uFFFD", 0: "\uFFFD",
'"': "&#34;", '"': "&#34;",
'&': "&amp;", '&': "&amp;",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment