This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,18 @@ Master: []|(?1))*\))$/ ' ;
84
+ const REGEX_COLUMN_EXPR = '/^([\w]*\s*\(([^\(\)]|(?1))*\))$/ ' ;
85
+ const REGEX_COLUMN_EXPR_ORDER = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/ ' ;
86
+ const REGEX_COLUMN_EXPR_GROUP = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/ ' ;
85
87
86
88
/**
87
89
* Bind variables for query
@@ -511,7 +513,7 @@ public function group($spec)
511
513
}
512
514
513
515
foreach ($ spec as $ val ) {
514
- if (preg_match (self ::REGEX_COLUMN_EXPR , (string ) $ val )) {
516
+ if (preg_match (self ::REGEX_COLUMN_EXPR_GROUP , (string ) $ val )) {
515
517
$ val = new Zend_Db_Expr ($ val );
516
518
}
517
519
$ this ->_parts [self ::GROUP ][] = $ val ;
@@ -603,7 +605,7 @@ public function order($spec)
603
605
$ val = trim ($ matches [1 ]);
604
606
$ direction = $ matches [2 ];
605
607
}
606
- if (preg_match (self ::REGEX_COLUMN_EXPR , (string ) $ val )) {
608
+ if (preg_match (self ::REGEX_COLUMN_EXPR_ORDER , (string ) $ val )) {
607
609
$ val = new Zend_Db_Expr ($ val );
608
610
}
609
611
$ this ->_parts [self ::ORDER ][] = array ($ val , $ direction );
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ final class Zend_Version
32
32
/**
33
33
* Zend Framework version identification - see compareVersion()
34
34
*/
35
- const VERSION = '1.12.19dev ' ;
35
+ const VERSION = '1.12.19 ' ;
36
36
37
37
/**
38
38
* The latest stable version Zend Framework available
Original file line number Diff line number Diff line change @@ -834,6 +834,10 @@ public function testSqlInjectionWithOrder()
834
834
$ select = $ this ->_db ->select ();
835
835
$ select ->from (array ('p ' => 'products ' ))->order ('MD5(1);drop table products; -- ) ' );
836
836
$ this ->assertEquals ('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);drop table products; -- )" ASC ' , $ select ->assemble ());
837
+
838
+ $ select = $ this ->_db ->select ();
839
+ $ select ->from ('p ' )->order ("MD5( \";( \");DELETE FROM p2; SELECT 1 #) " );
840
+ $ this ->assertEquals ('SELECT "p".* FROM "p" ORDER BY "MD5("";("");DELETE FROM p2; SELECT 1 #)" ASC ' , $ select ->assemble ());
837
841
}
838
842
839
843
public function testSqlInjectionWithGroup ()
@@ -845,6 +849,10 @@ public function testSqlInjectionWithGroup()
845
849
$ select = $ this ->_db ->select ();
846
850
$ select ->from (array ('p ' => 'products ' ))->group ('MD5(1); drop table products; -- ) ' );
847
851
$ this ->assertEquals ('SELECT "p".* FROM "products" AS "p" GROUP BY "MD5(1); drop table products; -- )" ' , $ select ->assemble ());
852
+
853
+ $ select = $ this ->_db ->select ();
854
+ $ select ->from ('p ' )->group ("MD5( \";( \");DELETE FROM p2; SELECT 1 #) " );
855
+ $ this ->assertEquals ('SELECT "p".* FROM "p" GROUP BY "MD5("";("");DELETE FROM p2; SELECT 1 #)" ' , $ select ->assemble ());
848
856
}
849
857
850
858
public function testSqlInjectionInColumn ()
You can’t perform that action at this time.
0 commit comments