Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Improved regex for SQL group, order, from #418

Merged
merged 1 commit into from
Aug 19, 2014

Conversation

ezimuel
Copy link
Contributor

@ezimuel ezimuel commented Aug 18, 2014

This is an improvement of Zend_Db_Select regarding the SQL regular expressions used in oder(), group() and from() functions. This fix is based on the feedbacks received in zf-security mailing list, about security advisory ZF2014-04. After some discussion, the reporters have decided that this is an application issue rather than an framework issue; however, we felt we could make the functionality more robust regardless.

@froschdesign froschdesign added this to the 1.12.8 milestone Aug 18, 2014
froschdesign added a commit that referenced this pull request Aug 19, 2014
Improved regex for SQL group, order, from
@froschdesign froschdesign merged commit 705122c into zendframework:master Aug 19, 2014
@croensch
Copy link
Contributor

What about functions with underscore like DATE_FORMAT()? I guess i would have to wrap that in Zend_Db_Expr myself.

@froschdesign
Copy link
Member

@croensch

I guess i would have to wrap that in Zend_Db_Expr myself.

Right.

Ping @ezimuel for confirmation.

@Ezo
Copy link

Ezo commented Aug 27, 2014

Just curious here.

As i wasn't wrapping all my expressions in Zend_Db_Expr, upgrading my (old) project to ZF1.2.8 broke some queries.
Of course it's good practice to use Zend_Db_Expr, but shouldn't a minor update be backward compatible?

@mpichot
Copy link

mpichot commented Aug 28, 2014

Hi there,

This improve broke some order by like new Zend_Db_Expr('TO_DAYS(STR_TO_DATE('.$field.',"%d/%m/%Y"))'). It results in TO_DAYS(STR_TO_DATE(debut,"%d/%m/%Y")). The back quotes are bad there. It must be TO_DAYS(STR_TO_DATE(debut,"%d/%m/%Y")).

Do I miss something ?

@druidvav
Copy link

This PR caused a bug: #424

@ezimuel
Copy link
Contributor Author

ezimuel commented Sep 3, 2014

I'm sorry that this "improvement" has break some code. We did this for security reason, see ZF2014-04. To fix this in existing code, you should use Zend_Db_Expr if your order(), group() or from() statements contain complex SQL statemente with nested functions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants