aizu-m opened a new pull request, #147:
URL: https://github.com/apache/poi-xmlbeans/pull/147
Schema `xs:token` with `pattern value='[^ ]*'`, instance
`<t:nospace>a<!--c--> b</t:nospace>` (a tab after the comment):
XmlObject.validate() -> true, no errors
getStringValue() -> "a b"
Same schema, enumeration `'a b'`, instance `<t:enum>a<!--c-->
b</t:enum>`:
error: cvc-enumeration-valid: string value 'a b' is not a valid
enumeration value for type of element enum in namespace urn:t
Found by comparing store validation against the getters for text split by a
comment or pi.
Timeline:
- `impl.store.Validate` skips COMMENT and PROCINST and joins the text around
them. Text in more than one chunk goes through `Locale.applyWhiteSpaceRule(s,
wsr)`.
- For WS_COLLAPSE that method has a fast path. It returns `s` unchanged
unless there is leading/trailing whitespace or two whitespace chars in a row.
- So a single tab, newline or CR between two non-space chars is never
replaced. Collapse must replace it first. The WS_REPLACE branch and
`ScrubBuffer.scrub` already do.
- Single-chunk text and the getters go through the scrub buffer. Only the
split-text validation path diverges.
Observation: facets are checked against `a\tb` while the application reads
`a b`. A pattern can be bypassed and valid enumeration values are rejected.
Conclusion: the fast path should hand any non-space whitespace char to
`processWhiteSpaceRule`. That is the fix. Strings already in collapsed form
still take the fast path. `SplitTextCollapseValidateTest` fails before the
change and passes after. `gradle test` is green (3226 tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]