Skip to content

fix inverted xsd length facet check in anyURI and NOTATION holders#45

Closed
aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:inverted-length-facet-check
Closed

fix inverted xsd length facet check in anyURI and NOTATION holders#45
aizu-m wants to merge 1 commit into
apache:trunkfrom
aizu-m:inverted-length-facet-check

Conversation

@aizu-m

@aizu-m aizu-m commented Jun 15, 2026

Copy link
Copy Markdown

Spotted while reading the *HolderEx facet checks side by side. The length-facet branch in JavaUriHolderEx.check reads:

if (length == m) {
    return false;
}

It returns "invalid" when the length matches, the opposite of the minLength/maxLength branches right below it. JavaNotationHolderEx.check has the same defect, spelt as the double negative !(v.length() != m).

Both sit on the validate-on-set path (set_text -> check). I compiled an anyURI restricted with xs:length value="5" and set values with VALIDATE_ON_SET:

len5 (matches facet)      : XmlValueOutOfRangeException   <- valid value rejected
len3 (violates xs:length) : accepted                      <- facet bypassed

So a correctly sized value is thrown out, and a wrong-length one slips past the length check entirely. JavaStringHolderEx and the validate_simpleval path already test length != m, so I flipped both conditions to agree with them.

Added a regression test that fails on trunk and passes with the change.

@pjfanning

Copy link
Copy Markdown
Member

merged with 568c4c6

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.

2 participants