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/es/cif.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/es/cif.py')
-rw-r--r-- | stdnum/es/cif.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/stdnum/es/cif.py b/stdnum/es/cif.py index 8802f87..982cdff 100644 --- a/stdnum/es/cif.py +++ b/stdnum/es/cif.py @@ -49,6 +49,7 @@ InvalidFormat: ... from stdnum import luhn from stdnum.es import dni from stdnum.exceptions import * +from stdnum.util import isdigits __all__ = ['compact', 'validate', 'is_valid', 'split'] @@ -70,7 +71,7 @@ def validate(number): """Check if the number provided is a valid DNI number. This checks the length, formatting and check digit.""" number = compact(number) - if not number[1:-1].isdigit(): + if not isdigits(number[1:-1]): raise InvalidFormat() if len(number) != 9: raise InvalidLength() |