Development

#2844: sfEmailValidator.patch

You must first sign up to be able to contribute.

Ticket #2844: sfEmailValidator.patch

File sfEmailValidator.patch, 3.5 kB (added by noel, 8 months ago)
  • test/unit/validator/sfEmailValidatorTest.php

    old new  
    33/* 
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  *  
     6 * 
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
    99 */ 
     
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212require_once($_test_dir.'/unit/sfContextMock.class.php'); 
    1313 
    14 $t = new lime_test(28, new lime_output_color()); 
     14$t = new lime_test(72, new lime_output_color()); 
    1515 
    1616$context = new sfContext(); 
    1717$v = new sfEmailValidator(); 
     
    2424  'fabien.potencier@symfony-project.com', 
    2525  'example@example.co.uk', 
    2626  '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', 
    2740); 
    2841 
    2942$invalidEmails = array( 
     
    3144  'example@', 
    3245  'example@localhost', 
    3346  '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  '&lt;script&gt;alert(1)&lt;/script&gt;@example.com', 
    3453); 
    3554 
    3655$validEmailsNotStrict = array( 
     
    4463  'example', 
    4564  'example@', 
    4665  'example@example.com@example.com', 
     66  'Abc..123@example.com', 
     67  'example@example..com', 
     68  '<script>alert(1)</script>@example.com', 
    4769); 
    4870 
    4971$v->initialize($context); 
  • lib/validator/sfEmailValidator.class.php

    old new  
    44 * This file is part of the symfony package. 
    55 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    66 * (c) 2004-2006 Sean Kerr <sean@code-box.org> 
    7  *  
     7 * 
    88 * For the full copyright and license information, please view the LICENSE 
    99 * file that was distributed with this source code. 
    1010 */ 
     
    3434    $strict = $this->getParameterHolder()->get('strict'); 
    3535    if ($strict == true) 
    3636    { 
    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 
    3850    } 
    3951    else 
    4052    {