Skip to content

Fix ichEnd offset bug in DoubleParser when input has leading whitespace#7668

Open
jelinekdev wants to merge 2 commits into
dotnet:mainfrom
jelinekdev:fix/doubleparser-ichend-offset
Open

Fix ichEnd offset bug in DoubleParser when input has leading whitespace#7668
jelinekdev wants to merge 2 commits into
dotnet:mainfrom
jelinekdev:fix/doubleparser-ichend-offset

Conversation

@jelinekdev

Copy link
Copy Markdown

Fixes #7181

Fixes the whitespace handling in DoubleParser.Parse when the input contains leading whitespace.

TryParse returns ichEnd relative to the sliced span. The subsequent validation compares it against the original span, which can incorrectly return Result.Extra for valid inputs such as " 1.234 ".

This change adjusts ichEnd back to the original span before validating the remaining characters.

Added unit tests covering:

  • parsing with leading and trailing whitespace (double)
  • parsing without whitespace
  • parsing with trailing invalid characters
  • parsing with leading and trailing whitespace (float)

@jelinekdev

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible bug in DoubleParser.cs

1 participant