report over-long float and double as invalid in validateLexical - #92
Open
aizu-m wants to merge 1 commit into
Open
report over-long float and double as invalid in validateLexical#92aizu-m wants to merge 1 commit into
aizu-m wants to merge 1 commit into
Conversation
pjfanning
reviewed
Aug 12, 2026
| try { | ||
| return XsTypeConverter.lexDouble(v, strict, maxNumberOfCharsForNumbers); | ||
| } catch (NumberFormatException e) { | ||
| } catch (IllegalArgumentException e) { |
Member
There was a problem hiding this comment.
maybe we should catch RuntimeException or just generally not tie to one exact exception type
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.
Found this feeding long numeric text through validate(). A float or double literal longer than the XmlOptions maxNumberOfCharsForNumbers cap (1024 by default) reaches MathUtil.parseAsFloat/parseAsDouble, which enforce the cap by throwing IllegalArgumentException. validateLexical in JavaFloatHolder and JavaDoubleHolder only catches NumberFormatException, so the exception leaves doc.validate() instead of being recorded as an XmlError.
Two observations. validate() throws rather than returning false. And a union such as
<xs:union memberTypes="xs:double xs:string"/>rejects a value that is valid against xs:string, because the validator probes the double member first and the exception escapes the member loop.NumberFormatException is a subclass of IllegalArgumentException, so widening the catch keeps every existing invalid-lexical case and folds the length cap into a reported error. Regression test drives a 1025-char float and double through validate().