Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overly permissive parsing after whitespace #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sholderbach
Copy link

Fix parsing logic after first whitespace

The way the parse was implemented accepted additional numeric characters
or . after the first valid f64 literal but ignored them.

This permitted more strings than are invalid following a strict grammar
for byte sizes and silently ignores the further symbols without error.

1.0 ...KB
1.0 42.0 B

This change makes those illegal.

1 000 B was also subject to the bad skip_while ignoring the
following 000. In this version of the fix whitespace is not accepted
as a digit separator. So it will raise an error if the user doesn't
explicitly strip the whitespace instead of reporting a wrong value.

The way the parse was implemented accepted additional numeric characters
or `.` after the first valid `f64` literal but ignored them.

This permitted more strings that are invalid following a strict grammar
for byte sizes and silently ignores the further symbols without error.

```
1.0 ...KB
1.0 42.0 B
```
This change makes those illegal.

`1 000 B` was also subject to the bad `skip_while` ignoring the
following `000`. In this version of the fix whitespace is not accepted
as a digit separator. So it will raise an error if the user doesn't
explicitly strip the whitespace instead of reporting a wrong value.
More following the old choices of using `f64::from_str`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant