[pLog-svn] r3920 - plog/trunk/class/data/validator/rules

Oscar Renalias oscar at renalias.net
Sat Sep 2 17:45:39 GMT 2006


Anybody up for some unit testing practice? :-)

We should definitely write a test case for this case, as it seems to  
be causing some trouble.

On 29 Aug 2006, at 19:18, mark at devel.lifetype.net wrote:

> Author: mark
> Date: 2006-08-29 16:18:33 +0000 (Tue, 29 Aug 2006)
> New Revision: 3920
>
> Modified:
>    plog/trunk/class/data/validator/rules/emailformatrule.class.php
> Log:
> Fixed a bug http://bugs.lifetype.net/view.php?id=1022.
>
> The original e-mail validator from PEAR, does not allow 163.com or  
> 126.com. So, we have to tweak the original regexp to get it work.
>
> Still have no time write a e-mail unit test. :(
>
> Modified: plog/trunk/class/data/validator/rules/ 
> emailformatrule.class.php
> ===================================================================
> --- plog/trunk/class/data/validator/rules/emailformatrule.class.php	 
> 2006-08-29 15:01:17 UTC (rev 3919)
> +++ plog/trunk/class/data/validator/rules/emailformatrule.class.php	 
> 2006-08-29 16:18:33 UTC (rev 3920)
> @@ -32,17 +32,17 @@
>           */
>          function validate($value)
>          {
> -
> -			// the base regexp for address
> -			$regex = '&^(?:                                               #  
> recipient:
> -			 ("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")|                           
> #1 quoted name
> -			 ([-\w!\#\$%\&\'*+~/^`|{}]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}]+)*))  
> #2 OR dot-atom
> -			 @(((\[)?                     #3 domain, 4 as IPv4, 5  
> optionally bracketed
> -			 (?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))\.){3}
> -				   (?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]?[0-9]))))(?(5) 
> \])|
> -			 ((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z](?:[-a-z0-9]*[a- 
> z0-9])?))  #6 domain as hostname
> -			 \.((?:[a-z]*[a-z])?) #7 ICANN domain names
> -			 $&xi';
> +	        // the base regexp for address
> +			// I get these code from PEAR::Validate v0.64
> +	        $regex = '&^ 
> (?:                                               # recipient:
> +	         ("\s*(?:[^"\f\n\r\t\v\b\s]+\s*) 
> +")|                          #1 quoted name
> +	         ([-\w!\#\$%\&\'*+~/^`|{}]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}]+) 
> *)) #2 OR dot-atom
> +	         @(((\[)?                     #3 domain, 4 as IPv4, 5  
> optionally bracketed
> +	         (?:(?:(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]? 
> [0-9]))\.){3}
> +	               (?:(?:25[0-5])|(?:2[0-4][0-9])|(?:[0-1]?[0-9]? 
> [0-9]))))(?(5)\])|
> +	         ((?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)*[a-z0-9](?:[-a- 
> z0-9]*[a-z0-9])?)  #6 domain as hostname
> +	         \.((?:([^-])[-a-z]*[-a-z])?)) #7 ICANN domain names
> +	         $&xi';
>  	
>  			if( preg_match($regex, $value) ){
>                  $this->_setError(false);
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
>



More information about the pLog-svn mailing list