This repository was archived by the owner on May 16, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -601,7 +601,7 @@ public function order($spec)
601601 $ val = trim ($ matches [1 ]);
602602 $ direction = $ matches [2 ];
603603 }
604- if (preg_match ('/\ (.*\)/ ' , $ val )) {
604+ if (preg_match ('/^[\w]*\ (.*\)$ / ' , $ val )) {
605605 $ val = new Zend_Db_Expr ($ val );
606606 }
607607 $ this ->_parts [self ::ORDER ][] = array ($ val , $ direction );
Original file line number Diff line number Diff line change @@ -1757,4 +1757,14 @@ public function testJoinUsingUsesAliasOfTableBeingJoinedWhenAliasIsDefined()
17571757 $ this ->assertRegexp ("/ON {$ table2_alias }. {$ colname }/s " , $ select ->assemble ());
17581758 }
17591759
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+ }
17601770}
You can’t perform that action at this time.
0 commit comments