From 3eeb3067e3578585ffb561dd1fc98f74f472ae0b Mon Sep 17 00:00:00 2001 From: Manuel Reinhard Date: Wed, 19 Mar 2014 12:36:45 +0100 Subject: [PATCH] Fix IBAN validator --- src/Symfony/Component/Validator/Constraints/IbanValidator.php | 4 ++-- .../Validator/Tests/Constraints/IbanValidatorTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/IbanValidator.php b/src/Symfony/Component/Validator/Constraints/IbanValidator.php index 3ec4c6ea7a..d26363f37b 100644 --- a/src/Symfony/Component/Validator/Constraints/IbanValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IbanValidator.php @@ -31,7 +31,7 @@ class IbanValidator extends ConstraintValidator } // An IBAN without a country code is not an IBAN. - if (0 === preg_match('/[A-Za-z]/', $value)) { + if (0 === preg_match('/[A-Z]/', $value)) { $this->context->addViolation($constraint->message, array('{{ value }}' => $value)); return; @@ -50,7 +50,7 @@ class IbanValidator extends ConstraintValidator .strval(ord($teststring{1}) - 55) .substr($teststring, 2, 2); - $teststring = preg_replace_callback('/[A-Za-z]/', function ($letter) { + $teststring = preg_replace_callback('/[A-Z]/', function ($letter) { return intval(ord(strtolower($letter[0])) - 87); }, $teststring); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php index d4add7930c..60ba94c32c 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/IbanValidatorTest.php @@ -182,6 +182,10 @@ class IbanValidatorTest extends \PHPUnit_Framework_TestCase array('foo'), array('123'), array('0750447346'), + + //Ibans with lower case values are invalid + array('Ae260211000000230064016'), + array('ae260211000000230064016') ); } }