This repository was archived by the owner on May 16, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -601,7 +601,7 @@ public function order($spec)
601
601
$ val = trim ($ matches [1 ]);
602
602
$ direction = $ matches [2 ];
603
603
}
604
- if (preg_match ('/\ (.*\)/ ' , $ val )) {
604
+ if (preg_match ('/^[\w]*\ (.*\)$ / ' , $ val )) {
605
605
$ val = new Zend_Db_Expr ($ val );
606
606
}
607
607
$ this ->_parts [self ::ORDER ][] = array ($ val , $ direction );
Original file line number Diff line number Diff line change @@ -1757,4 +1757,14 @@ public function testJoinUsingUsesAliasOfTableBeingJoinedWhenAliasIsDefined()
1757
1757
$ this ->assertRegexp ("/ON {$ table2_alias }. {$ colname }/s " , $ select ->assemble ());
1758
1758
}
1759
1759
1760
+ public function testSqlInjectionWithOrder ()
1761
+ {
1762
+ $ select = $ this ->_db ->select ();
1763
+ $ select ->from (array ('p ' => 'products ' ))->order ('MD5(1);select ' );
1764
+ $ this ->assertEquals ($ select , 'SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);select" ASC ' );
1765
+
1766
+ $ select = $ this ->_db ->select ();
1767
+ $ select ->from (array ('p ' => 'products ' ))->order ('name;select;MD5(1) ' );
1768
+ $ this ->assertEquals ($ select , 'SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC ' );
1769
+ }
1760
1770
}
You can’t perform that action at this time.
0 commit comments