Commit 54a1156
Fix overly permissive parsing after whitespace (bytesize-rs#59)
* 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 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.
* Add tests for invalid chars after whitespace
* Add test documenting that whitespace is not a valid digit separator
More following the old choices of using `f64::from_str`
---------
Co-authored-by: Rob Ede <[email protected]>1 parent 38536c3 commit 54a1156
1 file changed
+6
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| |||
219 | 217 | | |
220 | 218 | | |
221 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
| |||
0 commit comments