Repository navigation
fix: rejeita dígitos não ASCII na validação de CEP - #805
Open
LoboProgrammingg wants to merge 1 commit into
Open
LoboProgrammingg wants to merge 1 commit into
LoboProgrammingg wants to merge 1 commit into
Conversation
str.isdigit() aceita dígitos Unicode como '²', '0' e '٠', então
is_valid_cep('²' * 8) retornava True e format_cep formatava a entrada.
LoboProgrammingg
force-pushed
the
803
branch
from
November 20, 2026 17:18
3464916 to
25d2f38
Compare
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Descrição
is_valid_cepusava apenasstr.isdigit(), que também aceita dígitos Unicode. Por issois_valid_cep("²" * 8)retornavaTrueeformat_cep("²" * 8)devolvia"²²²²²-²²²". Agora o CEP precisa ter 8 dígitos ASCII (0-9).Mudanças Propostas
brutils/cep.py:is_validpassa a exigircep.isascii()além decep.isdigit(). Comoformat_cepdepende deis_valid, a correção vale para as duas funções.tests/test_cep.py: casos com algarismos sobrescritos (²), dígitos de largura total (0) e dígitos arábico-índicos (٠).README.mdeREADME_EN.mdagora dizem "dígitos de 0 a 9".CHANGELOG.mdemFixed.Checklist de Revisão
Declaração de Uso de IA (OBRIGATÓRIA)
Ferramenta utilizada: Claude Code. Revisei o diff e rodei os testes localmente.
Comentários Adicionais (opcional)
make checkverde.tests.test_cepverde, e o teste novo falha sem a mudança emcep.py.ibge.test_municipality(test_get_municipality_by_code_gzip_erroretest_get_municipality_by_code_gzip_generic_error) já falham namainsem este PR. Parecem depender de rede.cpf.py,pis.py,renavam.py,voter_id.pyelegal_process.pytambém validam comisdigit(). Não mexi neles para manter o PR restrito à issue; se fizer sentido, abro uma issue separada.Issue Relacionada
Closes #803