Skip to content

reject leading colon in xsd:QName values in JavaQNameHolder - #135

Open
aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:qname-empty-prefix
Open

aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:qname-empty-prefix

Conversation

@aizu-m

@aizu-m aizu-m commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Found while comparing the two xsd:QName lexical paths.

loader.parse("<t:root xmlns:t='urn:t'>:abc</t:root>", null, null).validate()
returned true, with the value parsed as the unprefixed name "abc"

JavaQNameHolder.parse splits the value at the first colon, but the prefix NCName check is guarded by prefix.length() > 0, so a colon with an empty prefix slips through: :abc is outside the xsd:QName lexical space, yet it parses as abc bound to the default namespace. parse is the path the streaming Validator uses for xsd:QName and xsd:NOTATION values (via JavaQNameHolderEx / JavaNotationHolderEx.validateLexical) and the set path for XmlQName, so the bad value flows in from untrusted XML and validates clean. The rich parser path, XsTypeConverter.lexQName, already rejects a leading colon.

The fix applies the existing prefix check whenever a colon is present; isValidNCName rejects the empty prefix like any other invalid one. Values without a colon and valid prefixed values are unchanged. Regression test added.

This fix was found and prepared with AI assistance and reviewed by me before submitting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant