From cc567915236b04372ce828ef0612551933074600 Mon Sep 17 00:00:00 2001 From: Diogo Zani Date: Sat, 28 Nov 2026 14:13:20 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20rejeita=20d=C3=ADgitos=20n=C3=A3o=20ASCI?= =?UTF-8?q?I=20na=20valida=C3=A7=C3=A3o=20de=20placa=20Mercosul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + brutils/license_plate.py | 2 +- tests/license_plate/test_is_valid.py | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c1db3f..2685d266 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- `is_valid_license_plate` aceitava placas Mercosul com dígitos de outros alfabetos, como `٤` [#818](https://github.com/brazilian-utils/python/issues/818) - Cálculo do dígito verificador em `is_valid_legal_process` e `generate_legal_process`, que rejeitava números de processo reais e gerava números inválidos [#785](https://github.com/brazilian-utils/python/pull/785) ## [2.5.0] - 2026-06-30 diff --git a/brutils/license_plate.py b/brutils/license_plate.py index 2faa2385..d58167f0 100644 --- a/brutils/license_plate.py +++ b/brutils/license_plate.py @@ -221,5 +221,5 @@ def _is_valid_mercosul(license_plate: str) -> bool: return False license_plate = license_plate.upper().strip() - pattern = re.compile(r"^[A-Z]{3}\d[A-Z]\d{2}$") + pattern = re.compile(r"^[A-Z]{3}\d[A-Z]\d{2}$", re.ASCII) return re.match(pattern, license_plate) is not None diff --git a/tests/license_plate/test_is_valid.py b/tests/license_plate/test_is_valid.py index 95d24c22..701d55d4 100644 --- a/tests/license_plate/test_is_valid.py +++ b/tests/license_plate/test_is_valid.py @@ -145,6 +145,11 @@ def test__is_valid_mercosul(self): # When license plate has separator, returns false self.assertIs(_is_valid_mercosul("ABC-1D23"), False) + # When license plate contains digits from other alphabets, + # returns False + self.assertIs(_is_valid_mercosul("ABC٤E٦٧"), False) + self.assertIs(_is_valid_mercosul("ABC4E67"), False) + # When license plate is valid self.assertIs(_is_valid_mercosul("ABC4E67"), True) self.assertIs(_is_valid_mercosul("AAA1A11"), True)