aizu-m opened a new pull request, #175:
URL: https://github.com/apache/poi-xmlbeans/pull/175
Differential run, `XmlObject.validate()` vs the JDK Xerces validator,
`xs:double` with `<xs:minInclusive value="0"/>`:
<v>NaN</v>
XB: VALID
XE: INVALID cvc-minInclusive-valid: Value 'NaN' is not facet-valid
with respect to minInclusive '0.0E1' for type 'T'.
How it was found: I ran NaN, INF, -INF and 0 against each of the four bound
facets on `xs:float` and `xs:double`, with bounds of 0, NaN, INF and -INF. 24
of the 128 cases disagreed with Xerces. Every one had NaN on exactly one side.
Observations:
- `JavaFloatHolder.compare` and `JavaDoubleHolder.compare` fall back to the
bit patterns, which puts NaN above every other value.
- So the max facets already reject a NaN value, but `minInclusive` and
`minExclusive` accept it. A NaN max bound accepts every number.
- XML Schema makes NaN equal to itself and incomparable with every other
value. Xerces reports every bound facet for those pairs.
- #132 fixed the same min-facet gap for dateTime and duration. It left float
and double alone because they looked totally ordered. NaN is the exception.
Conclusion: a schema that bounds a float or double with `minInclusive="0"`
does not keep NaN out, and NaN then slips past range checks in the code that
reads the value, since every comparison with it is false. The four bound checks
in `JavaFloatHolderEx.validateValue` and `JavaDoubleHolderEx.validateValue` now
also fail when exactly one side is NaN. NaN against a NaN bound, and every
non-NaN value, behave as before. After the fix all 128 cases agree with Xerces.
Cases added to `IncomparableMinFacetValidateTest`. `nanFailsEveryBound`
fails on trunk and passes with the fix. `./gradlew test` is otherwise green,
apart from `CompilationTests.partials` and `SaverTest.testLengthAssertion`,
which fail the same way on an untouched trunk checkout here on Windows (they
look like line-ending issues).
--
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]