Skip to content

Conversation

@sholderbach
Copy link

Replay of bytesize-rs#59

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.

Signed-off-by: sholderbach <sholderbach@users.noreply.github.com>
Signed-off-by: sholderbach <sholderbach@users.noreply.github.com>
More following the old choices of using `f64::from_str`

Signed-off-by: sholderbach <sholderbach@users.noreply.github.com>
@robjtede
Copy link

released original bytesize crate v1.3.1

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.

2 participants