fix: corrects sanitization to accept the entire alphabet in alphanume…#461
Open
lindsay-qive wants to merge 2 commits intobrazilian-utils:mainfrom
Open
fix: corrects sanitization to accept the entire alphabet in alphanume…#461lindsay-qive wants to merge 2 commits intobrazilian-utils:mainfrom
lindsay-qive wants to merge 2 commits intobrazilian-utils:mainfrom
Conversation
…BC.345/01DE-35) to prevent future regressions
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.
Description
This PR fixes the sanitization logic for the alphanumeric CNPJ (version 2), which was incorrectly restricting the allowed characters and silently removing valid letters (such as 'E', 'O', 'T', 'U').
Closes #460
What was changed
forloop and the restrictedallowedCharsstring with a standard.replace(/[^A-Za-z0-9]/g, '').toUpperCase().[A-Z0-9]range.Evidence / Official Context
According to the official FAQ document released by the Brazilian Federal Revenue (Receita Federal do Brasil), the alphanumeric CNPJ uses the
[A-Z0-9]base[cite: 22].Furthermore, the official example provided by the government for calculating the Verification Digit (Módulo 11) explicitly uses the letter E:
12.ABC.345/01DE-35. The previousallowedCharsimplementation was stripping this letter out, rendering valid official examples invalid.