Ticket #2844: sfEmailValidator.patch
| File sfEmailValidator.patch, 3.5 kB (added by noel, 8 months ago) |
|---|
-
test/unit/validator/sfEmailValidatorTest.php
old new 3 3 /* 4 4 * This file is part of the symfony package. 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 6 * 7 7 * For the full copyright and license information, please view the LICENSE 8 8 * file that was distributed with this source code. 9 9 */ … … 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 require_once($_test_dir.'/unit/sfContextMock.class.php'); 13 13 14 $t = new lime_test( 28, new lime_output_color());14 $t = new lime_test(72, new lime_output_color()); 15 15 16 16 $context = new sfContext(); 17 17 $v = new sfEmailValidator(); … … 24 24 'fabien.potencier@symfony-project.com', 25 25 'example@example.co.uk', 26 26 'fabien_potencier@example.fr', 27 'fabien-potencier@example.fr', 28 'example_example.foo.123.bar@subdomain.domain-example.com', 29 'Abc@example.com', 30 'Abc.123@example.com', 31 '1234567890@domain.com', 32 'abcd@example-one.com', 33 '_______@domain.com', 34 'user+mailbox/department=shipping@example.com', 35 'my-_.email.-_@example.com', 36 'myemail______@example.com', 37 'myemail______@example-example.123.com', 38 '!#$%&\'*+-/=?^_`.{|}~@example.com', 39 'example@example.museum', 27 40 ); 28 41 29 42 $invalidEmails = array( … … 31 44 'example@', 32 45 'example@localhost', 33 46 'example@example.com@example.com', 47 'example@example.com@example.com', 48 'example@invalid_example.com', 49 '<script>alert(1)</script>@example.com', 50 'Abc..123@example.com', 51 'example@example..com', 52 '<script>alert(1)</script>@example.com', 34 53 ); 35 54 36 55 $validEmailsNotStrict = array( … … 44 63 'example', 45 64 'example@', 46 65 'example@example.com@example.com', 66 'Abc..123@example.com', 67 'example@example..com', 68 '<script>alert(1)</script>@example.com', 47 69 ); 48 70 49 71 $v->initialize($context); -
lib/validator/sfEmailValidator.class.php
old new 4 4 * This file is part of the symfony package. 5 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 6 * (c) 2004-2006 Sean Kerr <sean@code-box.org> 7 * 7 * 8 8 * For the full copyright and license information, please view the LICENSE 9 9 * file that was distributed with this source code. 10 10 */ … … 34 34 $strict = $this->getParameterHolder()->get('strict'); 35 35 if ($strict == true) 36 36 { 37 $re = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; 37 /* 38 * From Wikipedia: http://en.wikipedia.org/wiki/E-mail_address 39 * According to RFC 2822, the local-part of the e-mail address may use any of these ASCII characters: 40 * Uppercase and lowercase letters 41 * The digits 0 through 9 42 * The characters ! # $ % * / ? | ^ { } ` ~ & ' + - = _ 43 * The character . provided that it is not the first nor last character in the local-part, nor may it appear two or more times consecutively 44 * 45 */ 46 $re = '/^([a-zA-Z0-9\!#\$%\*\/\?\|\^\{\}`~&\'\+\-=_])+' // allowed characters 47 .'(\.([a-zA-Z0-9\!#\$%\*\/\?\|\^\{\}`~&\'\+\-=_])+)*' // allowed characters + dot 48 .'\@' 49 .'(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/'; // domain 38 50 } 39 51 else 40 52 {