Skip to content

into filesize silently ignores certain invalid inputs and strips anything after the first whitespace. #14866

@sholderbach

Description

@sholderbach

Describe the bug

The upstream dependency bytesize had a significant flaw in its parsing logic which treated any digits or . after a first whitespace as if it where the whitespace separator to the unit part.

I already sent an upstream patch to bytesize. Based on #14397 we may alternatively choose to ditch that dependency as we already have a bunch of utility types handy and the parsing itself is trivial (and exists in a separate version for the more strict literal parsing of filesize)

How to reproduce

"1 000 B" | into filesize
#> 1 B
"2.0 ... B" | into filesize
#> 2 B
"3.0 99 KB" | into filesize
#> 3.0 KB

Expected behavior

Errors for illegal filesizes. (we may want to consider permitting space as a visual separator for strings like 1 000 B and interpret that as 1KB)

Configuration

key value
version 0.101.1
major 0
minor 101
patch 1
branch main
commit_hash 3f5ebd7
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.82.0 (f6e511eec 2024-10-15)
rust_channel 1.82.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.82.0 (8f40fc59f 2024-08-21)
build_time 2025-01-19 19:51:32 +01:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, trash
installed_plugins formats 0.99.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:error-silent-failCases where nothing or something bad happens and an error would be helpful and expectedcategory:bugSomething isn't workingcategory:upstreamproblem with upstream dependency

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions