Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -198,12 +198,14 @@ |
199 | 199 | return new AFPData( self::DBool, (bool)$result ); |
200 | 200 | } |
201 | 201 | |
202 | | - public static function keywordRegex( $str, $regex, $pos ) { |
| 202 | + public static function keywordRegex( $str, $regex, $pos, $insensitive = false ) { |
203 | 203 | $str = $str->toString(); |
204 | 204 | $pattern = $regex = $regex->toString(); |
205 | 205 | |
206 | 206 | $pattern = preg_replace( '!(\\\\\\\\)*(\\\\)?/!', '$1\/', $pattern ); |
207 | 207 | $pattern = "/$pattern/u"; |
| 208 | + |
| 209 | + if( $insensitive ) $pattern .= "i"; |
208 | 210 | |
209 | 211 | try { |
210 | 212 | set_error_handler( array( 'AbuseFilterParser', 'regexErrorHandler' ) ); |
— | — | @@ -215,6 +217,10 @@ |
216 | 218 | } |
217 | 219 | return new AFPData( self::DBool, (bool)$result ); |
218 | 220 | } |
| 221 | + |
| 222 | + public static function keywordRegexInsensitive( $str, $regex, $pos ) { |
| 223 | + return self::keywordRegex( $str, $regex, $pos, true ); |
| 224 | + } |
219 | 225 | |
220 | 226 | public static function unaryMinus( $data ) { |
221 | 227 | if ( $data->type == self::DInt ) { |
— | — | @@ -403,7 +409,7 @@ |
404 | 410 | ); |
405 | 411 | static $mKeywords = array( |
406 | 412 | 'in', 'like', 'true', 'false', 'null', 'contains', 'matches', |
407 | | - 'rlike', 'regex', 'if', 'then', 'else', 'end', |
| 413 | + 'rlike', 'irlike', 'regex', 'if', 'then', 'else', 'end', |
408 | 414 | ); |
409 | 415 | |
410 | 416 | static $parserCache = array(); |
— | — | @@ -837,6 +843,7 @@ |
838 | 844 | 'matches' => 'keywordLike', |
839 | 845 | 'contains' => 'keywordContains', |
840 | 846 | 'rlike' => 'keywordRegex', |
| 847 | + 'irlike' => 'keywordRegexInsensitive', |
841 | 848 | 'regex' => 'keywordRegex' |
842 | 849 | ); |
843 | 850 | if ( $this->mCur->type == AFPToken::TKeyword && in_array( $keyword, array_keys( $specwords ) ) ) { |
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | 'like' => 'like', |
51 | 51 | '""' => 'stringlit', |
52 | 52 | 'rlike' => 'rlike', |
| 53 | + 'irlike' => 'irlike', |
53 | 54 | 'cond ? iftrue : iffalse' => 'tern', |
54 | 55 | 'if cond then iftrue else iffalse end' => 'cond', |
55 | 56 | ), |
Index: trunk/extensions/AbuseFilter/AbuseFilter.i18n.php |
— | — | @@ -250,6 +250,7 @@ |
251 | 251 | 'abusefilter-edit-builder-misc-in' => 'contained in string (in)', |
252 | 252 | 'abusefilter-edit-builder-misc-like' => 'Matches pattern (like)', |
253 | 253 | 'abusefilter-edit-builder-misc-rlike' => 'Matches regex (rlike)', |
| 254 | + 'abusefilter-edit-builder-misc-rlike' => 'Matches regex, case insensitive (irlike)', |
254 | 255 | 'abusefilter-edit-builder-misc-contains' => 'Left string contains right string (contains)', |
255 | 256 | 'abusefilter-edit-builder-misc-stringlit' => 'String literal ("")', |
256 | 257 | 'abusefilter-edit-builder-misc-tern' => 'Ternary operator (X ? Y : Z)', |