r92020 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92019‎ | r92020 | r92021 >
Date:23:36, 12 July 2011
Author:nad
Status:ok
Tags:
Comment:
use preg_quote
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin.php (modified) (history)
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -282,16 +282,14 @@
283283 */
284284 function cmpCallback( $a, $b, $operator ) {
285285 $b = html_entity_decode( $b, ENT_QUOTES );
286 - $bre = str_replace( '/', '\/', $b );
287 - $bre = str_replace( '(', '\(', $bre );
288 - $bre = str_replace( ')', '\)', $bre );
 286+ $bre = preg_quote( $b, '|' );
289287 switch ( $operator ) {
290288 case '=':
291 - $cond = preg_match( "/$bre/i", $a );
 289+ $cond = preg_match( "|$bre|i", $a );
292290 break;
293291
294292 case '!=':
295 - $cond = !preg_match( "/$bre/i", $a );
 293+ $cond = !preg_match( "|$bre|i", $a );
296294 break;
297295
298296 default:
@@ -616,9 +614,7 @@
617615 $html = preg_replace( "|(<option[^<>]*) selected|i", "$1", $html ); # remove the currently selected option
618616 if( $v ) {
619617 foreach( self::split( $v ) as $v ) {
620 - $v = htmlentities( $v );
621 - $v = str_replace( '(', '\(', $v );
622 - $v = str_replace( ')', '\)', $v );
 618+ $v = preg_quote( htmlentities( $v ), '|' );
623619 $html = preg_match( "|<option[^>]+value\s*=|is", $html )
624620 ? preg_replace( "|(<option)([^>]+value\s*=\s*[\"']{$v}['\"])|is", "$1 selected$2", $html )
625621 : preg_replace( "|(<option[^>]*)(?=>$v</option>)|is", "$1 selected", $html );
Index: trunk/extensions/RecordAdmin/RecordAdmin.php
@@ -10,7 +10,7 @@
1111 * @author Siebrand Mazeland
1212 * @licence GNU General Public Licence 2.0 or later
1313 */
14 -define( 'RECORDADMIN_VERSION', '1.2.7, 2011-07-12' );
 14+define( 'RECORDADMIN_VERSION', '1.2.8, 2011-07-13' );
1515
1616 $dir = dirname( __FILE__ ) . '/';
1717 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';

Status & tagging log