(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:
Victor Vasiliev 2011-10-18 17:57:33 +00:00
parent 9075e03709
commit eca7343487
Notes: Raimond Spekking 2012-03-12 20:46:25 +00:00

View file

@ -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(