diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2019-04-28 23:35:42 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2019-04-29 21:31:14 +0200 |
commit | 48ff92e300696e2449070ac03b4916c76d4e77a3 (patch) | |
tree | 7cbdf6e9e626bd2cac7b98ca2ad5ac7436d5cdaa /stdnum/il/idnr.py | |
parent | 3aeec68735d75a4835122990bef232ed415b07d5 (diff) |
Use an internal isdigits() function instead of str.isdigit()
The problem with the latter is that it will also accept all kinds of
unicode digits that are not the ASCII 0-9 digits causing all kinds of
problems in check digit calculations.
Some of these unicode characters are also considered digits by int() but
some are not (such as the SUPERSCRIPT TWO unicode character).
Closes https://github.com/arthurdejong/python-stdnum/issues/96
Diffstat (limited to 'stdnum/il/idnr.py')
-rw-r--r-- | stdnum/il/idnr.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/stdnum/il/idnr.py b/stdnum/il/idnr.py index e638ab7..544d6df 100644 --- a/stdnum/il/idnr.py +++ b/stdnum/il/idnr.py @@ -45,7 +45,7 @@ InvalidLength: ... from stdnum import luhn from stdnum.exceptions import * -from stdnum.util import clean +from stdnum.util import clean, isdigits def compact(number): @@ -62,7 +62,7 @@ def validate(number): number = compact(number) if len(number) > 9: raise InvalidLength() - if not number.isdigit() or int(number) <= 0: + if not isdigits(number) or int(number) <= 0: raise InvalidFormat() luhn.validate(number) return number |