r47465 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47464‎ | r47465 | r47466 >
Date:19:42, 18 February 2009
Author:werdna
Status:ok
Tags:
Comment:
Add rmwhitespace function
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -303,6 +303,7 @@
304304 'specialratio' => 'funcSpecialRatio',
305305 'rmspecials' => 'funcRMSpecials',
306306 'rmdoubles' => 'funcRMDoubles',
 307+ 'rmwhitespace' => 'funcRMWhitespace',
307308 'count' => 'funcCount'
308309 );
309310
@@ -1003,6 +1004,10 @@
10041005 return AntiSpoof::listToString($ret);
10051006 }
10061007
 1008+ protected function rmwhitespace( $s ) {
 1009+ return preg_replace( '/\s+/u', '', $s );
 1010+ }
 1011+
10071012 protected function funcRMSpecials( $args ) {
10081013 if( count( $args ) < 1 )
10091014 throw new AFPExpection( "No params passed to ".__METHOD__ );
@@ -1013,6 +1018,16 @@
10141019 return new AFPData( AFPData::DString, $s );
10151020 }
10161021
 1022+ protected function funcRMWhitespace( $args ) {
 1023+ if( count( $args ) < 1 )
 1024+ throw new AFPExpection( "No params passed to ".__METHOD__ );
 1025+ $s = $args[0]->toString();
 1026+
 1027+ $s = $this->rmwhitespace( $s );
 1028+
 1029+ return new AFPData( AFPData::DString, $s );
 1030+ }
 1031+
10171032 protected function funcRMDoubles( $args ) {
10181033 if( count( $args ) < 1 )
10191034 throw new AFPExpection( "No params passed to ".__METHOD__ );
@@ -1031,6 +1046,7 @@
10321047 $s = $this->ccnorm($s);
10331048 $s = $this->rmdoubles( $s );
10341049 $s = $this->rmspecials( $s );
 1050+ $s = $this->rmwhitespace( $s );
10351051
10361052 return new AFPData( AFPData::DString, $s );
10371053 }

Status & tagging log