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

Oscar Renalias oscar at renalias.net
Fri Jun 16 19:44:05 GMT 2006


Mark, can you see if this still works well? It does for me. Stristr  
and strpos were just too generic to be used!

On 16 Jun 2006, at 22:11, oscar at devel.lifetype.net wrote:

> Author: oscar
> Date: 2006-06-16 19:11:30 +0000 (Fri, 16 Jun 2006)
> New Revision: 3589
>
> Modified:
>    plog/trunk/class/data/validator/rules/ 
> filteredpatternsrule.class.php
> Log:
> fixed an issue with this rule, I don't think it was really using  
> "rules" to filter out words because it was using strstr(). I've  
> converted to a "real" pattern matcher, or else having 'blog' in the  
> forbidden_usernames array would cause 'myblog', 'bloggggg' and all  
> other words with the 'blog' substring to fai as valid usernames and/ 
> or subdomain names.
>
>
> Modified: plog/trunk/class/data/validator/rules/ 
> filteredpatternsrule.class.php
> ===================================================================
> --- plog/trunk/class/data/validator/rules/ 
> filteredpatternsrule.class.php	2006-06-16 18:50:19 UTC (rev 3588)
> +++ plog/trunk/class/data/validator/rules/ 
> filteredpatternsrule.class.php	2006-06-16 19:11:30 UTC (rev 3589)
> @@ -41,14 +41,13 @@
>          function validate($value)
>          {
>  			foreach( $this->_filteredPatterns as $filteredPattern ) {
> -				if( $this->_caseSensitive )
> -				{
> -					if( strpos( $value, $filteredPattern ) !== false )
> -						return false;
> -				} else {
> -					if( stristr( $value, $filteredPattern ) !== false )
> -						return false;
> -				}
> +				$regexp = "/^$filteredPattern\$/";
> +				if( !$this->_caseSensitive )
> +					$regexp .= "i";
> +					
> +				$res = preg_match( $regexp, $value );
> +				if( $res > 0 )
> +					return false;	// no need to keep searching					
>  			}
>  			
>  			return true;
>
> _______________________________________________
> 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