doc/godebug.md | 5 +++++ src/html/template/attr_string.go | 5 +++-- src/html/template/context.go | 8 ++++++++ src/html/template/element_string.go | 5 +++-- src/html/template/escape.go | 14 ++++++++++++++ src/html/template/escape_test.go | 34 ++++++++++++++++++++++++++++++++++ src/html/template/state_string.go | 8 +++++--- src/html/template/transition.go | 47 +++++++++++++++++++++++++++++++++++++++++------ src/internal/godebugs/table.go | 1 + src/runtime/metrics/doc.go | 5 +++++ diff --git a/doc/godebug.md b/doc/godebug.md index 90ed63a01ad4588e668ce27a8e235477835e036e..dbec880c56c7ac4383d853bdf923a783a7e7be43 100644 --- a/doc/godebug.md +++ b/doc/godebug.md @@ -155,6 +155,11 @@ and the [go command documentation](/cmd/go#hdr-Build_and_test_caching). ### Go 1.26 +Go 1.26.1 added a new `htmlmetacontenturlescape` setting that controls whether +html/template will escape URLs in the `url=` portion of the content attribute of +HTML meta tags. The default `htmlmetacontentescape=1` will cause URLs to be +escaped. Setting `htmlmetacontentescape=0` disables this behavior. + Go 1.26 added a new `httpcookiemaxnum` setting that controls the maximum number of cookies that net/http will accept when parsing HTTP headers. If the number of cookie in a header exceeds the number set in `httpcookiemaxnum`, cookie parsing diff --git a/src/html/template/attr_string.go b/src/html/template/attr_string.go index 51c3f262084c04592e18c6c563070c706eac9ba2..7159fa9cbaa15a0b78c6c98324ad0133d180b05b 100644 --- a/src/html/template/attr_string.go +++ b/src/html/template/attr_string.go @@ -14,11 +14,12 @@ _ = x[attrScriptType-2] _ = x[attrStyle-3] _ = x[attrURL-4] _ = x[attrSrcset-5] + _ = x[attrMetaContent-6] } -const _attr_name = "attrNoneattrScriptattrScriptTypeattrStyleattrURLattrSrcset" +const _attr_name = "attrNoneattrScriptattrScriptTypeattrStyleattrURLattrSrcsetattrMetaContent" -var _attr_index = [...]uint8{0, 8, 18, 32, 41, 48, 58} +var _attr_index = [...]uint8{0, 8, 18, 32, 41, 48, 58, 73} func (i attr) String() string { if i >= attr(len(_attr_index)-1) { diff --git a/src/html/template/context.go b/src/html/template/context.go index b78f0f7325ed66545278250aabd421bd82e78920..8b3af2feabd8aa9199c1599cfff19dc455d4f431 100644 --- a/src/html/template/context.go +++ b/src/html/template/context.go @@ -156,6 +156,10 @@ stateCSSLineCmt // stateError is an infectious error state outside any valid // HTML/CSS/JS construct. stateError + // stateMetaContent occurs inside a HTML meta element content attribute. + stateMetaContent + // stateMetaContentURL occurs inside a "url=" tag in a HTML meta element content attribute. + stateMetaContentURL // stateDead marks unreachable code after a {{break}} or {{continue}}. stateDead ) @@ -267,6 +271,8 @@ // elementTextarea corresponds to the RCDATA