Index: trunk/extensions/AbuseFilter/AbuseFilter.parser.php |
— | — | @@ -794,8 +794,9 @@ |
795 | 795 | |
796 | 796 | // Spaces |
797 | 797 | $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]); |
800 | 801 | } |
801 | 802 | |
802 | 803 | if( $offset >= strlen($code) ) return array( '', AFPToken::TNone, $code, $offset ); |
— | — | @@ -824,8 +825,7 @@ |
825 | 826 | if( $code[$offset] == '"' || $code[$offset] == "'" ) { |
826 | 827 | $type = $code[$offset]; |
827 | 828 | $offset++; |
828 | | - $strLen = $len = strlen($code); |
829 | | - while( $offset < $strLen ) { |
| 829 | + while( $offset < strlen($code) ) { |
830 | 830 | |
831 | 831 | if( $code[$offset] == $type ) { |
832 | 832 | $offset++; |
— | — | @@ -839,22 +839,16 @@ |
840 | 840 | $tok .= substr( $code, $offset, $addLength ); |
841 | 841 | $offset += $addLength; |
842 | 842 | } elseif( $code[$offset] == '\\' ) { |
843 | | - switch( $code[$offset + 1] ) { |
844 | | - case '\\': |
| 843 | + if( $code[$offset + 1] == '\\' ) |
845 | 844 | $tok .= '\\'; |
846 | | - break; |
847 | | - case $type: |
| 845 | + elseif( $code[$offset + 1] == $type ) |
848 | 846 | $tok .= $type; |
849 | | - break; |
850 | | - case 'n'; |
| 847 | + elseif( $code[$offset + 1] == 'n' ) |
851 | 848 | $tok .= "\n"; |
852 | | - break; |
853 | | - case 'r': |
| 849 | + elseif( $code[$offset + 1] == 'r' ) |
854 | 850 | $tok .= "\r"; |
855 | | - break; |
856 | | - case 't': |
| 851 | + elseif( $code[$offset + 1] == 't' ) |
857 | 852 | $tok .= "\t"; |
858 | | - break; |
859 | 853 | elseif( $code[$offset + 1] == 'x' ) { |
860 | 854 | $chr = substr( $code, $offset + 2, 2 ); |
861 | 855 | |
— | — | @@ -888,15 +882,15 @@ |
889 | 883 | |
890 | 884 | foreach( self::$mOps as $op ) |
891 | 885 | $quoted_operators[] = preg_quote( $op, '/' ); |
892 | | - $operator_regex = '/('.implode('|', $quoted_operators).')/A'; |
| 886 | + $operator_regex = '/('.implode('|', $quoted_operators).')/'; |
893 | 887 | } |
894 | 888 | |
895 | 889 | $matches = array(); |
896 | 890 | |
897 | | - preg_match( $operator_regex, $code, $matches, 0, $offset ); |
| 891 | + preg_match( $operator_regex, $code, $matches, PREG_OFFSET_CAPTURE, $offset ); |
898 | 892 | |
899 | | - if( count( $matches ) ) { |
900 | | - $tok = $matches[0]; |
| 893 | + if( count( $matches ) && $matches[0][1] == $offset ) { |
| 894 | + $tok = $matches[0][0]; |
901 | 895 | $offset += strlen( $tok ); |
902 | 896 | return array( $tok, AFPToken::TOp, $code, $offset ); |
903 | 897 | } |
— | — | @@ -913,14 +907,14 @@ |
914 | 908 | 10 => '[0-9.]', |
915 | 909 | ); |
916 | 910 | $baseClass = '['.implode('', array_keys($bases)).']'; |
917 | | - $radixRegex = "/([0-9A-Fa-f]*(?:\.\d*)?)($baseClass)?/Au"; |
| 911 | + $radixRegex = "/([0-9A-Fa-f]*(?:\.\d*)?)($baseClass)?/u"; |
918 | 912 | $matches = array(); |
919 | 913 | |
920 | | - preg_match( $radixRegex, $code, $matches, 0, $offset ); |
| 914 | + preg_match( $radixRegex, $code, $matches, PREG_OFFSET_CAPTURE, $offset ); |
921 | 915 | |
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]; |
925 | 919 | $num = null; |
926 | 920 | |
927 | 921 | // Sometimes the base char gets mixed in with the rest of it because |
— | — | @@ -967,11 +961,12 @@ |
968 | 962 | // The rest are considered IDs |
969 | 963 | |
970 | 964 | // Regex match > PHP |
971 | | - $idSymbolRegex = '/[0-9A-Za-z_]+/A'; |
| 965 | + $idSymbolRegex = '/[0-9A-Za-z_]+/'; |
972 | 966 | $matches = array(); |
| 967 | + preg_match( $idSymbolRegex, $code, $matches, PREG_OFFSET_CAPTURE, $offset ); |
973 | 968 | |
974 | | - if ( preg_match( $idSymbolRegex, $code, $matches, 0, $offset ) ) { |
975 | | - $tok = $matches[0]; |
| 969 | + if ( $matches[0][1] == $offset ) { |
| 970 | + $tok = $matches[0][0]; |
976 | 971 | |
977 | 972 | $type = in_array( $tok, self::$mKeywords ) |
978 | 973 | ? AFPToken::TKeyword |
— | — | @@ -1206,4 +1201,4 @@ |
1207 | 1202 | return preg_match("#^".strtr(preg_quote($pattern, '#'), array('\*' => '.*', '\?' => '.'))."$#i", $string); |
1208 | 1203 | } // end |
1209 | 1204 | |
1210 | | -} // end if |
| 1205 | +} // end if |
\ No newline at end of file |