소스 검색

qubes/utils: parse_size: Fix string comparison

This commit resolves a bug which causes strings such as "350MiB" to be
rejected by parse_size, due to the fact that parse_size changes the case
of letters in the input string ("350MiB") to uppercase ("350MIB"), but
fails to do the same for the elements of the units conversion table.

The correction is simple: Apply the same case change to the units
table elements before comparison.
M. Vefa Bicakci 5 년 전
부모
커밋
d934e8114a
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      qubes/utils.py

+ 1 - 1
qubes/utils.py

@@ -100,7 +100,7 @@ def parse_size(size):
         return int(size)
 
     for unit, multiplier in units:
-        if size.endswith(unit):
+        if size.endswith(unit.upper()):
             size = size[:-len(unit)].strip()
             return int(size) * multiplier