Skip to content

Reject non-ASCII case equivalents in IBANs - #512

Merged
nandgator merged 2 commits into
python-validators:masterfrom
JunaidAhamed-7777:fix-iban-ascii-casefold
Oct 22, 2026
Merged

nandgator merged 2 commits into
python-validators:masterfrom
JunaidAhamed-7777:fix-iban-ascii-casefold

Conversation

@JunaidAhamed-7777

Copy link
Copy Markdown
Contributor

The case-insensitive IBAN regex currently accepts Unicode case equivalents of ASCII letters. For example, iban("\u0131T60X0542811101000000123456") and iban("GB82WE\u017fT12345698765432") return True: dotless i and long s match [a-z] and become ASCII letters during the checksum calculation.

Add re.ASCII to the format check and regression tests covering the country code and account identifier. Existing lowercase and mixed-case ASCII IBAN support is preserved.

Validation on Python 3.14:

  • Both new regression cases failed before the fix.
  • All 8 IBAN tests pass after the fix.
  • The full local test run passed 1,097 tests; 18 Ethereum-address tests failed because the optional Ethereum hashing dependency is not installed. CI includes that extra.
  • git diff --check passed. Ruff and Pyright are left to CI.

AI-assisted using GPT-6; human review follows draft submission.

@nandgator

Copy link
Copy Markdown
Collaborator

Thanks, the fix is correct and I'd like to merge it. CI's lint step (ruff check .) fails on tests/test_iban.py:28, though: E501, the line is 102 characters and the limit is 100. Running ruff format and pushing should fix it.

@JunaidAhamed-7777

Copy link
Copy Markdown
Contributor Author

Thanks, Ran Ruff and pushed the formatting fix. Lint, type checks, and all tests pass locally
@nandgator set alle?

@nandgator
nandgator merged commit b330d82 into python-validators:master Oct 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants