[pLog-svn] r3589 - plog/trunk/class/data/validator/rules
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Jun 16 19:11:31 GMT 2006
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;
More information about the pLog-svn
mailing list