Changeset 399


Ignore:
Timestamp:
Jun 22, 2012 2:25:43 PM (12 years ago)
Author:
anonymous
Message:

Updated email address validation

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Email.inc.php

    r396 r399  
    9090        // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatenation . dot.
    9191        // This matches a (valid) email address as complex as:
    92         //      "Jane & Bob Smith" <bob&smith's/dep=sales!@smith-wick.ca.us> (Sales department)
     92        //      "Jane & Bob Smith" <bob&smith's/dep=sales!@smith-wick.ca.us > (Sales department)
    9393        // ...and something as simple as:
    9494        //      x@x.com
    95         $this->setParam(array('regex' => '/^(?:(?:"[^"]*?"\s*|[^,@]*)(<)|(?:"[^"]*?"|[^,@]*)\s+|)'   // Display name
     95        $this->setParam(array('regex' => '/^(?:(?:"[^"]*?"\s*|[^,@]*)(<\s*)|(?:"[^"]*?"|[^,@]*)\s+|)'   // Display name
    9696        . '((?:[^.<>\s@",\[\]]+[^<>\s@",\[\]])*[^.<>\s@",\[\]]+)'       // Local-part
    9797        . '@'                                                           // @
     
    102102        . '[.-]?(?:[A-Z0-9]+[-.])*(?:[A-Z0-9]+\.)+[A-Z]{2,6}))'         // FALSE, matches domain name
    103103        . '(?(1)'                                                       // Comment conditional for if initial < exists
    104         . '(?:>\s*|>\s+\([^,@]+\)\s*)'                                  // TRUE, ensure ending >
     104        . '(?:\s*>\s*|>\s+\([^,@]+\)\s*)'                                  // TRUE, ensure ending >
    105105        . '|'
    106106        . '(?:|\s*|\s+\([^,@]+\)\s*))$/i'));                            // FALSE ensure there is no ending >
  • trunk/tests/EmailTest.php

    r396 r399  
    113113            }
    114114        }
    115         $this->assertEquals(41, $gc, 'Unexpected good count.');
    116         $this->assertEquals(47, $bc, 'Unexpected bad count.');
     115        $this->assertEquals(45, $gc, 'Unexpected number of valid emails found.');
     116        $this->assertEquals(45, $bc, 'Unexpected number of invalid emails found.');
    117117        // echo "Good addresses: $gc\n";
    118118        // echo "Bad addresses: $bc\n";
    119 //        echo join("\n", $bad);
    120 //        echo "\n";
     119        // echo join("\n", $bad);
     120        // echo "\n";
    121121    }
    122122
  • trunk/tests/_email_test_addresses.txt

    r42 r399  
    2222cthornhill_94%1@yahoo.com
    2323    "bob!#$%&'*+-/=?^_`.{|}~rice@domain.com",
    24 müllér@domain.com
     24mÃŒllér@domain.com
    2525sarah.adams.2008@femba.ucla.edu
    2626dig@whap.heck.suddenly.willy.sam.digity.okay.com.org
     
    4848< asdf@domain.com>
    4949<asdf@domain.com >
     50Mr. Asdf < asdf@domain.com>
     51Mr. Asdf <asdf@domain.com >
    5052asdf@domain.com>
    5153<asdf@domain.com
  • trunk/tests/run_tests.sh

    r357 r399  
    33# Be in the directory with all the tests.
    44cd `dirname $0`;
     5
     6# Create database.
     7mysql -e 'CREATE DATABASE IF NOT EXISTS `test`';
    58
    69# Run tests sequentially.
Note: See TracChangeset for help on using the changeset viewer.