mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-25 03:08:16 +00:00
(part of this commit is in r100135 due to SVN fail)
* (bug 24109) Add regex escaping function to abuse filter Patch by Jérémie Roquet
This commit is contained in:
parent
9075e03709
commit
eca7343487
Notes:
Raimond Spekking
2012-03-12 20:46:25 +00:00
|
@ -446,6 +446,7 @@ class AbuseFilterParser {
|
|||
'strlen' => 'funcLen',
|
||||
'strpos' => 'funcStrPos',
|
||||
'str_replace' => 'funcStrReplace',
|
||||
'rescape' => 'funcStrRegexEscape',
|
||||
'set' => 'funcSetVar',
|
||||
'set_var' => 'funcSetVar',
|
||||
);
|
||||
|
@ -1742,6 +1743,17 @@ class AbuseFilterParser {
|
|||
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(
|
||||
|
|
Loading…
Reference in a new issue