https://wicg.github.io/sanitizer-api/#sanitize-core, step 1.5.9.5.3 reads:
"If the built-in animating URL attributes list contains «[elementName, attrName]» and attr’s value is "href" or "xlink:href", then remove attribute."
https://dom.spec.whatwg.org/#dom-element-setattributens, step 1, calls "validate and extract", which reads:
- If qualifiedName contains a U+003A (:):
- Let splitResult be the result of running strictly split given qualifiedName and U+003A (:).
[...]
- Set localName to splitResult[1].
For a qualifiedName "xlink:href:abc", this would set localName to "href". The ":abc" is discarded. Blink implements this as specified:
d = document.createElement("div");
d.setAttributeNS("https://www.w3.org/1999/xlink", "xlink:href:abc", "https://www.example.org");
d.attributes[0] // xlink.href="https://www.example.org"
d.attributes[0].localName // "href"
SVG Animations is surprisingly vague about what the attributeName value means. I guess in XML-world it didn't have to. Blink has implemented <svg:set attributeName> to also use "validate and extract" to parse its value as a qualified name, so that <svg:set attributeName="xlink:href:abc"> would animate the target element's href attribute. This is rather surprising and, worse, is a bypass of the Sanitizer API guarantees.
By my reading, Blink's implementation matches the specs. Admittedly, with the rather large caveat that it's not particularly clear how SVG, or actually SVG-in-HTML-syntax, wants attributeName to be interpreted. If my reading of the spec is correct, then the string comparison in "sanitizer core" is insufficient.
Original report here.
https://wicg.github.io/sanitizer-api/#sanitize-core, step 1.5.9.5.3 reads:
https://dom.spec.whatwg.org/#dom-element-setattributens, step 1, calls "validate and extract", which reads:
For a qualifiedName "xlink:href:abc", this would set localName to "href". The ":abc" is discarded. Blink implements this as specified:
SVG Animations is surprisingly vague about what the
attributeNamevalue means. I guess in XML-world it didn't have to. Blink has implemented<svg:set attributeName>to also use "validate and extract" to parse its value as a qualified name, so that<svg:set attributeName="xlink:href:abc">would animate the target element'shrefattribute. This is rather surprising and, worse, is a bypass of the Sanitizer API guarantees.By my reading, Blink's implementation matches the specs. Admittedly, with the rather large caveat that it's not particularly clear how SVG, or actually SVG-in-HTML-syntax, wants
attributeNameto be interpreted. If my reading of the spec is correct, then the string comparison in "sanitizer core" is insufficient.Original report here.