Fix electronicFormatIBAN() mapping non-ASCII characters into A-Z - #691
Open
kinu01 wants to merge 1 commit into
Open
Fix electronicFormatIBAN() mapping non-ASCII characters into A-Z#691kinu01 wants to merge 1 commit into
kinu01 wants to merge 1 commit into
Conversation
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.
Fixes #690.
electronicFormatIBAN()calledString.prototype.toUpperCase(), which applies full Unicode case mapping. Characters like U+FB01 (fi), U+00DF (ß) and U+0131 (ı) map intoA-Z, sometimes expanding one character into two. SinceisValidIBAN()does not normalise its own input, those strings were validated as real IBANs.This changes the uppercasing to ASCII only, so any character outside the ISO 13616 set survives normalisation and is rejected by the country's BBAN pattern.
src/ibantools.ts: ASCII-only uppercase, with a comment explaining why the built-in cannot be used here.test/ibantools_test.js: 8 regression tests. All 8 fail on master and pass with the fix. Also adds a lowercase input test forelectronicFormatIBAN(), since the existing Brazilian test has no lowercase letters and so did not cover the new callback.ChangeLog: entry added.No behaviour change for valid input. Both README examples, lowercase input and spaced or dashed input all still normalise exactly as before.
npm run allpasses: 270 tests, lint clean, docs build. Coverage onbuild/ibantools.jsis unchanged at 99.76% statements and 100% functions (branch coverage goes from 90.74% to 90.78%).I left
dist,jsnextanddocsout of the diff as CONTRIBUTING asks.