Development

Changeset 1426

You must first sign up to be able to contribute.

Changeset 1426

Show
Ignore:
Timestamp:
06/13/06 08:23:08 (2 years ago)
Author:
slickrick
Message:

* Somehow my changes weren't uploaded for that last commit. Lets try again :) (Fixes Ticket #462)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/slickrick/lib/validator/sfEmailValidator.class.php

    r1425 r1426  
    3232  public function execute (&$value, &$error) 
    3333  { 
    34     /* Cal Henderson: http://iamcal.com/publish/articles/php/parsing_email/pdf/ 
    35      * The long regular expression below is made by the following code 
    36      * fragment: 
    37      * 
    38      *   $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; 
    39      *   $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; 
    40      *   $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c' 
    41      *         . '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; 
    42      *   $quoted_pair = '\\x5c\\x00-\\x7f'; 
    43      *   $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; 
    44      *   $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; 
    45      *   $domain_ref = $atom; 
    46      *   $sub_domain = "($domain_ref|$domain_literal)"; 
    47      *   $word = "($atom|$quoted_string)"; 
    48      *   $domain = "$sub_domain(\\x2e$sub_domain)*"; 
    49      *   $local_part = "$word(\\x2e$word)*"; 
    50      *   $addr_spec = "$local_part\\x40$domain"; 
    51      */ 
    52     $re = '/^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-' 
    53          .'\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c\\x00-' 
    54          .'\\x7f)*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' 
    55          .'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80' 
    56          .'-\\xff]|\\x5c\\x00-\\x7f)*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29' 
    57          .'\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^' 
    58          .'\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c\\x00-\\x7f)*\\x5d)(\\x2e([^\\x00-' 
    59          .'\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-' 
    60          .'\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c\\x00-\\x7f)*' 
    61          .'\\x5d))*$/' 
    62     ; 
     34    $strict = $this->getParameterHolder()->get('strict'); 
     35    if ($strict == true) 
     36    { 
     37      $re = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; 
     38    } 
     39    else  
     40    { 
     41 
     42      /* Cal Henderson: http://iamcal.com/publish/articles/php/parsing_email/pdf/ 
     43       * The long regular expression below is made by the following code 
     44       * fragment: 
     45       * 
     46       *   $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; 
     47       *   $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; 
     48       *   $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c' 
     49       *         . '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; 
     50       *   $quoted_pair = '\\x5c\\x00-\\x7f'; 
     51       *   $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; 
     52       *   $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; 
     53       *   $domain_ref = $atom; 
     54       *   $sub_domain = "($domain_ref|$domain_literal)"; 
     55       *   $word = "($atom|$quoted_string)"; 
     56       *   $domain = "$sub_domain(\\x2e$sub_domain)*"; 
     57       *   $local_part = "$word(\\x2e$word)*"; 
     58       *   $addr_spec = "$local_part\\x40$domain"; 
     59       */ 
     60       
     61      $re = '/^([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-' 
     62           .'\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c\\x00-' 
     63           .'\\x7f)*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-' 
     64           .'\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80' 
     65           .'-\\xff]|\\x5c\\x00-\\x7f)*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28\\x29' 
     66           .'\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^' 
     67           .'\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c\\x00-\\x7f)*\\x5d)(\\x2e([^\\x00-' 
     68           .'\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-' 
     69           .'\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff]|\\x5c\\x00-\\x7f)*' 
     70           .'\\x5d))*$/' 
     71      ; 
     72    } 
    6373     
    64     $re = '/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i'; 
    65  
    6674    if (!preg_match($re, $value)) 
    6775    {