Repository navigation
🐛 fix(xsd): validate prefixed attributes - #2330
Merged
Merged
Conversation
Prefixed attributes were skipped by the XSD attribute check, so declared prefixed attributes were never validated and xs:anyAttribute namespace and processContents settings never applied to them. Match each attribute by namespace name, resolved through the declarations in scope, against declared attributes and attribute wildcards. xmlns declarations and the xsi:type, xsi:nil, xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes stay unchecked. Refs tox-dev#2291
A prefixed attribute whose prefix has no declaration in scope was skipped, so an invalid attribute passed silently. An HTML-parsed tree keeps such a name literally, so the whole name is now an attribute in no namespace and is matched against no-namespace declarations and wildcards like any other undeclared attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
XML Schema validation skipped every attribute whose name carries a prefix, so a namespace-qualified attribute passed whatever the schema said about its namespace or its type (#2291). 🔐 Once this merges, an attribute that an
xs:anyAttributenamespace rule forbids is rejected, and a declared prefixed attribute is checked against its declared type.A prefixed attribute now matches a declaration or a wildcard by the namespace name its prefix binds in scope, the same way an unprefixed attribute already matched by its local name. The validator keeps the namespace lookup on the element that owns the attributes, so the cost sits on attributes that have a prefix. ✨ The trade-off: the
xsi:type,xsi:nil,xsi:schemaLocationandxsi:noNamespaceSchemaLocationattributes stay unchecked, as XML Schema 1.1 Part 1, section 3.4.4.2 allows, andxmlnsdeclarations are not attributes to check.Behavior changes
An undeclared
xml:attribute, such asxml:lang, is now reported unless a wildcard admits it, as the specification requires. An undeclared prefixed attribute that no wildcard admits is reported the same way an undeclared unprefixed one already was. A prefix with no declaration in scope leaves the whole name as an attribute in no namespace, so it is checked against no-namespace declarations and wildcards and reported when neither admits it.Fixes #2291