Repository navigation
Trim only ASCII white space under AllowLeadingWhite and AllowTrailingWhite [patch] - #182
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
…White [patch] TrimAllowedWhite called ReadOnlySpan<char>.TrimStart()/TrimEnd(), which strip everything char.IsWhiteSpace accepts: NBSP, U+202F, U+3000, NEL, LS, PS and the other Unicode space separators. NumberStyles allows only U+0009-U+000D and U+0020, and decimal, double and int reject the rest, so PreciseNumber accepted input every BCL numeric type refuses (for example a stray trailing fr-FR group separator, "1 ", under Integer). The trim now uses that explicit set. Fixes #181 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4JrXevVTQZvqzLBX1
|
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.



Fixes #181
What was wrong
TrimAllowedWhitetrimmed withReadOnlySpan<char>.TrimStart()andTrimEnd(), which remove anythingchar.IsWhiteSpaceaccepts: NBSP, U+202F, U+3000, NEL, LS, PS and the other Unicode space separators.NumberStylesallows only U+0009–U+000D and U+0020 as white space, anddecimal,doubleandintreject the rest.Parse/TryParsetherefore accepted input that every BCL numeric type refuses. The realistic case is a stray trailing fr-FR group separator,"1 ", underNumberStyles.Integer.What changed
" \t\n\v\f\r", held in a documentedAllowedWhiteconstant.Tests
Parse_RejectsNonAsciiWhiteSpaceAroundTheNumbercovers leading NBSP, trailing U+3000, leading NEL and trailing LS. Each case first asserts thatdecimal.TryParserejects the input, then asserts thatPreciseNumber.TryParsereturnsfalseandParsethrowsFormatException.Parse_RejectsATrailingNarrowSpaceGroupSeparatorWhenTheStyleDoesNotAllowThousandsis the fr-FR case from the issue. It uses the test file's existingNarrowSpaceGroupsformat rather thanfr-FR, so it also runs where the globalization-invariant mode has no culture data.Parse_TrimsAsciiWhiteSpaceAroundTheNumbershows that space, tab, CR, LF, VT and FF are still trimmed on both sides.Generated by Claude Code