r67791 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67790‎ | r67791 | r67792 >
Date:09:10, 10 June 2010
Author:daniel
Status:deferred
Tags:
Comment:
fix sanity check on field name in query generation; add regression test
Modified paths:
  • /trunk/extensions/DataTransclusion/DBDataTransclusionSource.php (modified) (history)
  • /trunk/extensions/DataTransclusion/tests/DataTransclusionTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransclusion/tests/DataTransclusionTest.php
@@ -309,6 +309,10 @@
310310
311311 $sql = $source->getQuery( 'id', '3' );
312312 $this->assertTrue( preg_match( '/WHERE \( *id *= *3 *\)/', $sql ) === 1 );
 313+
 314+ // check blocking of evil field names
 315+ $sql = $source->getQuery( 'name = 0; select * from x;', 'foo' );
 316+ $this->assertEquals( $sql, false );
313317 }
314318
315319 function testWebDataTransclusionSource() {
Index: trunk/extensions/DataTransclusion/DBDataTransclusionSource.php
@@ -84,7 +84,7 @@
8585 $db = wfGetDB( DB_SLAVE );
8686 }
8787
88 - if ( !preg_match( '/\w+[\w\d]+/', $field ) ) {
 88+ if ( !preg_match( '/^\w+[\w\d]+$/', $field ) ) {
8989 return false; // redundant, but make extra sure we don't get anythign evil here //TESTME
9090 }
9191

Status & tagging log