Remove more XML-derived attribute name validation - #11453
Conversation
* Change the behavior of the dataset named setter. * Change the conformance-related definitions for custom data attributes and custom element attributes. Closes #11439.
annevk
left a comment
There was a problem hiding this comment.
I didn't quite realize this when we made the change for custom elements, but this does mean that HTML and XHTML have now diverged in what they can express. This was already the case to some extent in various scenarios so that's probably okay.
|
I implemented the dataset logic in chromium already because the code for setAttribute which looks at the name validation is called by the dataset code. WPT was updated here: https://github.com/web-platform-tests/wpt/pull/53251/files#diff-cc0595be8cdff8311f0c29be67f13dfecfba203b2a8966b7353dfb8f341d701c I'm guessing that the custom elements changes are not testable. |
|
Thanks very much @josepharhar! Then, let me merge this, under the assumption we have enough Gecko and WebKit support to proceed. If that turns out to be a bad assumption, I will revert. |
…efixes r=smaug,dom-core,devtools-reviewers,ochameau Implement "relaxed" element/attribute name-validation rules, per: - whatwg/dom#1079 - whatwg/html#7991 - whatwg/html#11453 That aligns DOM-API name behavior with HTML parser behavior - which has always allowed a wider range of characters in element and attribute names. New validation functions in nsContentUtils: - IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation - IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute - no null, whitespace, /, >, or = - IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or > - IsValidDoctypeName(): For createDocumentType - no null, whitespace, or > - ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm per the DOM spec: for qualified names with multiple colons like "f:o:o", the local name is just the second token ("o"), not everything after the first colon ("o:o"). This matches the spec's requirement to split on all colons and use only splitResult[0] as prefix and splitResult[1] as localName. Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name validation rules; WPT name-validation.html provides coverage for the new relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass. Differential Revision: https://phabricator.services.mozilla.com/D277822
…efixes r=smaug,dom-core,devtools-reviewers,ochameau Implement "relaxed" element/attribute name-validation rules, per: - whatwg/dom#1079 - whatwg/html#7991 - whatwg/html#11453 That aligns DOM-API name behavior with HTML parser behavior - which has always allowed a wider range of characters in element and attribute names. New validation functions in nsContentUtils: - IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation - IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute - no null, whitespace, /, >, or = - IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or > - IsValidDoctypeName(): For createDocumentType - no null, whitespace, or > - ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm per the DOM spec: for qualified names with multiple colons like "f:o:o", the local name is just the second token ("o"), not everything after the first colon ("o:o"). This matches the spec's requirement to split on all colons and use only splitResult[0] as prefix and splitResult[1] as localName. Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name validation rules; WPT name-validation.html provides coverage for the new relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass. Differential Revision: https://phabricator.services.mozilla.com/D277822
…efixes r=smaug,dom-core,devtools-reviewers,ochameau Implement "relaxed" element/attribute name-validation rules, per: - whatwg/dom#1079 - whatwg/html#7991 - whatwg/html#11453 That aligns DOM-API name behavior with HTML parser behavior - which has always allowed a wider range of characters in element and attribute names. New validation functions in nsContentUtils: - IsValidElementLocalName(): For createElement - allows [A-Za-z] start followed by any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation - IsValidAttributeName(): For setAttribute/toggleAttribute/createAttribute - no null, whitespace, /, >, or = - IsValidNamespacePrefix(): For *NS methods - no null, whitespace, /, or > - IsValidDoctypeName(): For createDocumentType - no null, whitespace, or > - ParseQualifiedNameRelaxed(): Validates and parses qualified names with relaxed rules ParseQualifiedNameRelaxed() correctly implements the "strictly split" algorithm per the DOM spec: for qualified names with multiple colons like "f:o:o", the local name is just the second token ("o"), not everything after the first colon ("o:o"). This matches the spec's requirement to split on all colons and use only splitResult[0] as prefix and splitResult[1] as localName. Deleted outdated DOM Level 1 mochitest tests that tested old XML-based name validation rules; WPT name-validation.html provides coverage for the new relaxed rules. Removed WPT expected-failure .ini files, since all tests now pass. Differential Revision: https://phabricator.services.mozilla.com/D277822
https://bugs.webkit.org/show_bug.cgi?id=241419 Reviewed by Darin Adler. Implement relaxed name-validation rules per whatwg/dom#1079, whatwg/html#7991, and whatwg/html#11453. This aligns DOM API name behavior with HTML parser behavior — which has always allowed a wider range of characters in element and attribute names. New validation functions in NameValidation.h/cpp: - isValidElementName(): For createElement — allows [A-Za-z] start followed by any char except null/whitespace/>//, or [:_>=0x80] start with restricted continuation - isValidAttributeName(): For setAttribute/toggleAttribute/createAttribute — no null, whitespace, /, >, or = - isValidNamespacePrefix(): For *NS methods — no null, whitespace, /, or > - isValidDoctypeName(): For createDocumentType — no null, whitespace, or > - isValidXMLName(): Preserves old XML Name production for createProcessingInstruction * LayoutTests/fast/dom/dataset-expected.txt: * LayoutTests/fast/dom/dataset-xhtml-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocument.html: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createDocumentType-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createAttribute-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS.html: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS.js: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/attributes-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/dom/nodes/name-validation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/global-attributes/dataset-set-expected.txt: * LayoutTests/platform/glib/http/tests/misc/acid3-expected.txt: * LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt: * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocumentType): * Source/WebCore/dom/Document.cpp: (WebCore::createHTMLElementWithNameValidation): (WebCore::Document::createElementForBindings): (WebCore::Document::createProcessingInstruction): (WebCore::Document::createElementNS): (WebCore::Document::createAttribute): (WebCore::Document::createAttributeNS): (WebCore::isValidNameStart): Deleted. (WebCore::isValidNamePart): Deleted. (WebCore::isValidHTMLElementName): (WebCore::Document::hasValidNamespaceForElements): Deleted. (WebCore::Document::hasValidNamespaceForAttributes): Deleted. (WebCore::isValidNameNonASCII): Deleted. (WebCore::isValidNameASCII): Deleted. (WebCore::isValidNameASCIIWithoutColon): Deleted. (WebCore::Document::isValidName): Deleted. (WebCore::Document::parseQualifiedName): Deleted. * Source/WebCore/dom/Document.h: * Source/WebCore/dom/Element.cpp: (WebCore::Element::toggleAttribute): (WebCore::Element::setAttribute): (WebCore::Element::setAttributeNS): (WebCore::Element::parseAttributeName): * Source/WebCore/dom/Element.h: * Source/WebCore/dom/NameValidation.cpp: Added. (WebCore::NameValidation::isInvalidAttributeNameCharacter): (WebCore::NameValidation::isInvalidElementNameCharacterAfterAlphaStart): (WebCore::NameValidation::isValidElementNameContinuationCharacter): (WebCore::NameValidation::isInvalidNamespacePrefixCharacter): (WebCore::NameValidation::isInvalidDoctypeNameCharacter): (WebCore::NameValidation::isValidElementName): (WebCore::NameValidation::isValidAttributeName): (WebCore::NameValidation::isValidNamespacePrefix): (WebCore::NameValidation::isValidDoctypeName): (WebCore::NameValidation::isValidASCIIXMLName): (WebCore::NameValidation::isValidXMLNameStart): (WebCore::NameValidation::isValidXMLNamePart): (WebCore::NameValidation::isValidXMLName): (WebCore::NameValidation::parseQualifiedNameToPair): (WebCore::NameValidation::parseQualifiedElementName): (WebCore::NameValidation::parseQualifiedAttributeName): (WebCore::NameValidation::hasValidNamespaceForElements): (WebCore::NameValidation::hasValidNamespaceForAttributes): * Source/WebCore/dom/NameValidation.h: Added. * Source/WebCore/dom/Node.cpp: (WebCore::Node::checkSetPrefix): * Source/WebCore/dom/ProcessingInstruction.cpp: * Source/WebCore/editing/EditorCommand.cpp: (WebCore::executeFormatBlock): * Source/WebCore/svg/animation/SVGSMILElement.cpp: (WebCore::SVGSMILElement::constructAttributeName const): * Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp: (WebCore::handleNamespaceAttributes): (WebCore::handleElementAttributes): Canonical link: https://commits.webkit.org/308884@main
Closes #11439.
(See WHATWG Working Mode: Changes for more details.)
/custom-elements.html ( diff )
/dom.html ( diff )
/infrastructure.html ( diff )