From acab8e0c781c2143d22bbc12379df3bf235f601f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 18 Jan 2021 01:08:35 -0800 Subject: [PATCH] Don't remove spaces from input string. This was allowing inputs like "5 5" to equal 55. --- voussoirkit/bytestring.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voussoirkit/bytestring.py b/voussoirkit/bytestring.py index e0e0f2d..541f82a 100644 --- a/voussoirkit/bytestring.py +++ b/voussoirkit/bytestring.py @@ -108,7 +108,7 @@ def normalize_unit_string(string): ''' Given a string "k" or "kb" or "kib" in any case, return "KiB", etc. ''' - string = string.lower() + string = string.lower().strip() for (size, unit_string) in UNIT_STRINGS.items(): unit_string_l = unit_string.lower() if string in (unit_string_l, unit_string_l[0], unit_string_l.replace('i', '')): @@ -121,7 +121,7 @@ def parsebytes(string): Accepts "k", "kb", "kib" in any casing. ''' string = string.lower().strip() - string = string.replace(' ', '').replace(',', '') + string = string.replace(',', '') matches = re.findall(r'[\d\.-]+', string) if len(matches) == 0: