Skip to content

Commit f7936a8

Browse files
committed
Fix IBAN validator vulnerability with lowercase letter handling
1 parent 70de324 commit f7936a8

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/validators/iban.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def iban(value: str, /):
3737
(Literal[True]): If `value` is a valid IBAN code.
3838
(ValidationError): If `value` is an invalid IBAN code.
3939
"""
40+
if not value:
41+
return False
42+
value = value.upper()
4043
return (
41-
(re.match(r"^[a-z]{2}[0-9]{2}[a-z0-9]{11,30}$", value, re.IGNORECASE) and _mod_check(value))
42-
if value
43-
else False
44-
)
44+
re.match(r"^[A-Z]{2}[0-9]{2}[A-Z0-9]{11,30}$", value) and _mod_check(value)
45+
)

0 commit comments

Comments
 (0)