http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100139
Revision: 100139
Author: vasilievvv
Date: 2011-10-18 17:57:33 +0000 (Tue, 18 Oct 2011)
Log Message:
-----------
(part of this commit is in r100135 due to SVN fail)
* (bug 24109) Add regex escaping function to abuse filter
Patch by J?\195?\169r?\195?\169mie Roquet
Modified Paths:
--------------
trunk/extensions/AbuseFilter/AbuseFilter.parser.php
Modified: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
===================================================================
--- trunk/extensions/AbuseFilter/AbuseFilter.parser.php 2011-10-18 17:57:32 UTC
(rev 100138)
+++ trunk/extensions/AbuseFilter/AbuseFilter.parser.php 2011-10-18 17:57:33 UTC
(rev 100139)
@@ -446,6 +446,7 @@
'strlen' => 'funcLen',
'strpos' => 'funcStrPos',
'str_replace' => 'funcStrReplace',
+ 'rescape' => 'funcStrRegexEscape',
'set' => 'funcSetVar',
'set_var' => 'funcSetVar',
);
@@ -1742,6 +1743,17 @@
return new AFPData( AFPData::DString, str_replace( $search,
$replace, $subject ) );
}
+ protected function funcStrRegexEscape( $args ) {
+ if ( count( $args ) < 1 ) {
+ throw new AFPUserVisibleException( 'notenoughargs',
$this->mCur->pos,
+ array( 'rescape', 1, count(
$args ) ) );
+ }
+
+ $string = $args[0]->toString();
+
+ return new AFPData( AFPData::DString, preg_quote( $string ) );
+ }
+
protected function funcSetVar( $args ) {
if ( count( $args ) < 2 ) {
throw new AFPUserVisibleException(
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs