Skip to content

String-comparison against "href" + "xlink:href" #373

@otherdaniel

Description

@otherdaniel

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:

  1. If qualifiedName contains a U+003A (:):
    1. Let splitResult be the result of running strictly split given qualifiedName and U+003A (:).
      [...]
    2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions