Don't remove spaces from input string.

This was allowing inputs like "5 5" to equal 55.
This commit is contained in:
voussoir 2021-01-18 01:08:35 -08:00
parent 8a0ed3d131
commit acab8e0c78
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -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: