http://www.mediawiki.org/wiki/Special:Code/MediaWiki/91947

Revision: 91947
Author:   nad
Date:     2011-07-12 11:33:24 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
escape brackets before using in regex for filtering matching records by field

Modified Paths:
--------------
    trunk/extensions/RecordAdmin/RecordAdmin.php
    trunk/extensions/RecordAdmin/RecordAdmin_body.php

Modified: trunk/extensions/RecordAdmin/RecordAdmin.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin.php        2011-07-12 10:58:29 UTC 
(rev 91946)
+++ trunk/extensions/RecordAdmin/RecordAdmin.php        2011-07-12 11:33:24 UTC 
(rev 91947)
@@ -10,7 +10,7 @@
  * @author Siebrand Mazeland
  * @licence GNU General Public Licence 2.0 or later
  */
-define( 'RECORDADMIN_VERSION', '1.2.6, 2011-07-12' );
+define( 'RECORDADMIN_VERSION', '1.2.7, 2011-07-12' );
 
 $dir = dirname( __FILE__ ) . '/';
 $wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'RecordAdmin.i18n.php';

Modified: trunk/extensions/RecordAdmin/RecordAdmin_body.php
===================================================================
--- trunk/extensions/RecordAdmin/RecordAdmin_body.php   2011-07-12 10:58:29 UTC 
(rev 91946)
+++ trunk/extensions/RecordAdmin/RecordAdmin_body.php   2011-07-12 11:33:24 UTC 
(rev 91947)
@@ -281,14 +281,17 @@
         * - $b is the expression from the recordtable query
         */
        function cmpCallback( $a, $b, $operator ) {
-               $b = str_replace( '/', '\/', html_entity_decode( $b, ENT_QUOTES 
) );
+               $b = html_entity_decode( $b, ENT_QUOTES );
+               $bre = str_replace( '/', '\/', $b );
+               $bre = str_replace( '(', '\(', $bre );
+               $bre = str_replace( ')', '\)', $bre );
                switch ( $operator ) {
                        case '=':
-                               $cond = preg_match( "/$b/i", $a );
+                               $cond = preg_match( "/$bre/i", $a );
                        break;
                        
                        case '!=':
-                               $cond = !preg_match( "/$b/i", $a );
+                               $cond = !preg_match( "/$bre/i", $a );
                        break;
                        
                        default:


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to