diff options
| author | Mike Samuel <mikesamuel@gmail.com> | 2017-11-20 06:37:07 +0900 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2017-12-14 19:54:38 +0000 |
| commit | c0cda71dab6785c4b7a400b79796b23affe7f664 (patch) | |
| tree | cc71a242f29527c9b5dddecf680a4ff50a447fdf /src/html/template/context.go | |
| parent | c7b7c433637ba7bf14328e0fbccdd4bdbc5f65b3 (diff) | |
| download | go-c0cda71dab6785c4b7a400b79796b23affe7f664.tar.xz | |
html/template: add srcset content type
Srcset is largely the same as a URL, but is escaped in URL contexts.
Inside a srcset attribute, URLs have their commas percent-escaped to
avoid having the URL be interpreted as multiple URLs. Srcset is placed
in a srcset attribute literally.
Fixes #17441
Change-Id: I676b544784c7e54954ddb91eeff242cab25d02c4
Reviewed-on: https://go-review.googlesource.com/38324
Reviewed-by: Kunpei Sakai <namusyaka@gmail.com>
Reviewed-by: Mike Samuel <mikesamuel@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/html/template/context.go')
| -rw-r--r-- | src/html/template/context.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/html/template/context.go b/src/html/template/context.go index 37a3faf88b..50730d3f2b 100644 --- a/src/html/template/context.go +++ b/src/html/template/context.go @@ -102,6 +102,8 @@ const ( stateAttr // stateURL occurs inside an HTML attribute whose content is a URL. stateURL + // stateSrcset occurs inside an HTML srcset attribute. + stateSrcset // stateJS occurs inside an event handler or script element. stateJS // stateJSDqStr occurs inside a JavaScript double quoted string. @@ -145,6 +147,7 @@ var stateNames = [...]string{ stateRCDATA: "stateRCDATA", stateAttr: "stateAttr", stateURL: "stateURL", + stateSrcset: "stateSrcset", stateJS: "stateJS", stateJSDqStr: "stateJSDqStr", stateJSSqStr: "stateJSSqStr", @@ -326,6 +329,8 @@ const ( attrStyle // attrURL corresponds to an attribute whose value is a URL. attrURL + // attrSrcset corresponds to a srcset attribute. + attrSrcset ) var attrNames = [...]string{ @@ -334,6 +339,7 @@ var attrNames = [...]string{ attrScriptType: "attrScriptType", attrStyle: "attrStyle", attrURL: "attrURL", + attrSrcset: "attrSrcset", } func (a attr) String() string { |
