fix(i18n): reject invalid input in ind_pan and fr_ssn#469
Open
Jordan-Bourillot wants to merge 2 commits into
Open
fix(i18n): reject invalid input in ind_pan and fr_ssn#469Jordan-Bourillot wants to merge 2 commits into
Jordan-Bourillot wants to merge 2 commits into
Conversation
The SSN regex used the character classes [1,2] and 2[A,B], which also
match a literal comma. fr_ssn(', 84 12 76 451 089') was therefore
accepted as valid. Drop the commas ([12] and [AB]); valid SSNs are
unaffected.
ind_pan used re.match(r"[A-Z]{5}\d{4}[A-Z]{1}", ...) with no trailing $,
so any string starting with a valid PAN was accepted -- e.g.
ind_pan('ABCDE9999KEXTRA') returned a match. Anchor the pattern with
^...$, matching the ind_aadhar style just above it.
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.
Two small regex-correctness fixes in the i18n validators; each currently lets invalid input through. Both are covered by new regression tests that fail on
masterand pass with this change.ruffis clean and the full suite passes.ind_pan— trailing characters acceptedind_panusedre.match(r"[A-Z]{5}\d{4}[A-Z]{1}", value)with no trailing$.re.matchonly anchors the start, so any string that begins with a valid PAN was accepted:Anchored the pattern with
^…$, matching theind_aadharpattern just above it.fr_ssn— comma accepted as gender / Corsica suffixThe SSN regex used the character classes
[1,2]and2[A,B], which also match a literal comma:Dropped the commas (
[12]and[AB]). Valid SSNs are unaffected.