r48803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48802‎ | r48803 | r48804 >
Date:10:57, 25 March 2009
Author:werdna
Status:ok
Tags:
Comment:
Revert half-done patch from r48802
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.parser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php
@@ -794,8 +794,9 @@
795795
796796 // Spaces
797797 $matches = array();
798 - if ( preg_match( '/\s+/uA', $code, $matches, 0, $offset ) ) {
799 - $offset += strlen($matches[0]);
 798+ if ( preg_match( '/\s+/u', $code, $matches, PREG_OFFSET_CAPTURE, $offset ) &&
 799+ $matches[0][1] == $offset ) {
 800+ $offset += strlen($matches[0][0]);
800801 }
801802
802803 if( $offset >= strlen($code) ) return array( '', AFPToken::TNone, $code, $offset );
@@ -824,8 +825,7 @@
825826 if( $code[$offset] == '"' || $code[$offset] == "'" ) {
826827 $type = $code[$offset];
827828 $offset++;
828 - $strLen = $len = strlen($code);
829 - while( $offset < $strLen ) {
 829+ while( $offset < strlen($code) ) {
830830
831831 if( $code[$offset] == $type ) {
832832 $offset++;
@@ -839,22 +839,16 @@
840840 $tok .= substr( $code, $offset, $addLength );
841841 $offset += $addLength;
842842 } elseif( $code[$offset] == '\\' ) {
843 - switch( $code[$offset + 1] ) {
844 - case '\\':
 843+ if( $code[$offset + 1] == '\\' )
845844 $tok .= '\\';
846 - break;
847 - case $type:
 845+ elseif( $code[$offset + 1] == $type )
848846 $tok .= $type;
849 - break;
850 - case 'n';
 847+ elseif( $code[$offset + 1] == 'n' )
851848 $tok .= "\n";
852 - break;
853 - case 'r':
 849+ elseif( $code[$offset + 1] == 'r' )
854850 $tok .= "\r";
855 - break;
856 - case 't':
 851+ elseif( $code[$offset + 1] == 't' )
857852 $tok .= "\t";
858 - break;
859853 elseif( $code[$offset + 1] == 'x' ) {
860854 $chr = substr( $code, $offset + 2, 2 );
861855
@@ -888,15 +882,15 @@
889883
890884 foreach( self::$mOps as $op )
891885 $quoted_operators[] = preg_quote( $op, '/' );
892 - $operator_regex = '/('.implode('|', $quoted_operators).')/A';
 886+ $operator_regex = '/('.implode('|', $quoted_operators).')/';
893887 }
894888
895889 $matches = array();
896890
897 - preg_match( $operator_regex, $code, $matches, 0, $offset );
 891+ preg_match( $operator_regex, $code, $matches, PREG_OFFSET_CAPTURE, $offset );
898892
899 - if( count( $matches ) ) {
900 - $tok = $matches[0];
 893+ if( count( $matches ) && $matches[0][1] == $offset ) {
 894+ $tok = $matches[0][0];
901895 $offset += strlen( $tok );
902896 return array( $tok, AFPToken::TOp, $code, $offset );
903897 }
@@ -913,14 +907,14 @@
914908 10 => '[0-9.]',
915909 );
916910 $baseClass = '['.implode('', array_keys($bases)).']';
917 - $radixRegex = "/([0-9A-Fa-f]*(?:\.\d*)?)($baseClass)?/Au";
 911+ $radixRegex = "/([0-9A-Fa-f]*(?:\.\d*)?)($baseClass)?/u";
918912 $matches = array();
919913
920 - preg_match( $radixRegex, $code, $matches, 0, $offset );
 914+ preg_match( $radixRegex, $code, $matches, PREG_OFFSET_CAPTURE, $offset );
921915
922 - if ( count( $matches ) ) {
923 - $input = $matches[1];
924 - $baseChar = @$matches[2];
 916+ if ( count( $matches ) && $matches[0][1] == $offset ) {
 917+ $input = $matches[1][0];
 918+ $baseChar = @$matches[2][0];
925919 $num = null;
926920
927921 // Sometimes the base char gets mixed in with the rest of it because
@@ -967,11 +961,12 @@
968962 // The rest are considered IDs
969963
970964 // Regex match > PHP
971 - $idSymbolRegex = '/[0-9A-Za-z_]+/A';
 965+ $idSymbolRegex = '/[0-9A-Za-z_]+/';
972966 $matches = array();
 967+ preg_match( $idSymbolRegex, $code, $matches, PREG_OFFSET_CAPTURE, $offset );
973968
974 - if ( preg_match( $idSymbolRegex, $code, $matches, 0, $offset ) ) {
975 - $tok = $matches[0];
 969+ if ( $matches[0][1] == $offset ) {
 970+ $tok = $matches[0][0];
976971
977972 $type = in_array( $tok, self::$mKeywords )
978973 ? AFPToken::TKeyword
@@ -1206,4 +1201,4 @@
12071202 return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string);
12081203 } // end
12091204
1210 -} // end if
 1205+} // end if
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r48802Remove OBSOLETE file for PasswordResetwerdna10:55, 25 March 2009

Status & tagging log