8000 bug #10494 [2.3][Validator] Minor fix in IBAN validator (sprain) · symfony/symfony@65f0242 · GitHub
[go: up one dir, main page]

Skip to content

Commit 65f0242

Browse files
committed
bug #10494 [2.3][Validator] Minor fix in IBAN validator (sprain)
This PR was merged into the 2.3 branch. Discussion ---------- [2.3][Validator] Minor fix in IBAN validator | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10481, #10489 | License | MIT Added more values to unit tests of IBAN validator to make clear it doesn't accept lower case letters. > Permitted IBAN characters are the digits 0 to 9 and the 26 upper-case Latin alphabetic characters A to Z. http://en.wikipedia.org/wiki/International_Bank_Account_Number Also made little adjustment to code which meant to validate lowercase letters but actually was useless. Commits ------- 3eeb306 Fix IBAN validator
2 parents c29b421 + 3eeb306 commit 65f0242

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Symfony/Component/Validator/Constraints/IbanValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function validate($value, Constraint $constraint)
3131
}
3232

3333
// An IBAN without a country code is not an IBAN.
34-
if (0 === preg_match('/[A-Za-z]/', $value)) {
34+
if (0 === preg_match('/[A-Z]/', $value)) {
3535
$this->context->addViolation($constraint->message, array('{{ value }}' => $value));
3636

3737
return;
@@ -50,7 +50,7 @@ public function validate($value, Constraint $constraint)
5050
.strval(ord($teststring{1}) - 55)
5151
.substr($teststring, 2, 2);
5252

53-
$teststring = preg_replace_callback('/[A-Za-z]/', function ($letter) {
53+
$teststring = preg_replace_callback('/[A-Z]/', function ($letter) {
5454
return intval(ord(strtolower($letter[0])) - 87);
5555
}, $teststring);
5656

src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ public function getInvalidIbans()
182182
array('foo'),
183183
array('123'),
184184
array('0750447346'),
185+
186+
//Ibans with lower case values are invalid
187+
array('Ae260211000000230064016'),
188+
array('ae260211000000230064016')
185189
);
186190
}
187191
}

0 commit comments

Comments
 (0)
0