Repository navigation
Reject non-ASCII digits in checksum modules and ie.pps - #528
Open
adityakale2002 wants to merge 1 commit into
Open
adityakale2002 wants to merge 1 commit into
adityakale2002 wants to merge 1 commit into
Conversation
int() accepts digits from other scripts (e.g. ARABIC-INDIC DIGIT ONE), so the damm, verhoeff and iso7064 mod_11_2, mod_11_10 and mod_97_10 modules treated such values as valid digits. This also affected the lei and iso11649 modules which build on mod_97_10. The ie.pps format check used \d which has the same problem. Reject non-ASCII input with InvalidFormat and use an explicit ASCII character class in ie.pps. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #527.
int()accepts digits from other scripts (e.g.'٣', ARABIC-INDIC DIGIT THREE), so these modules treat such characters as ordinary digits:damm,verhoeff,iso7064.mod_11_2,mod_11_10andmod_97_10:validate()accepts them as valid input.leiandiso11649build onmod_97_10, so they accepted them as well.ie.pps: the format check uses\d, which also matches them.stdnum.util.isdigits()already notes that non-ASCII digits are not wanted, so this makes these modules consistent with it. The checksum modules now raiseInvalidFormatfor non-ASCII input (str(number)is used so non-string input keeps raising only validation errors, astest_robustnessrequires), andie.ppsuses[0-9].I left
eg.tnalone since it converts Arabic digits on purpose. I found the affected modules by converting every valid number in the doctests to Arabic-Indic digits and checking which validators still accepted them.Tests: one doctest in each affected module's test file (
damm,verhoeff,iso7064,ie_pps,lei,iso11649). All fail before the change and pass after; the full suite passes.Written with the help of Claude Code, and I reviewed the change and ran the tests.
🤖 Generated with Claude Code