cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid/DataSource DataObject.php

From: Date: Tue, 24 Oct 2006 15:29:11 +0000
Subject: cvs: pear /Structures_DataGrid DataGrid.php /Structures_DataGrid/DataGrid/DataSource DataObject.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-42787@lists.php.net to get a copy of this message
olivierg Tue Oct 24 15:29:11 2006 UTC Modified files: /pear/Structures_DataGrid DataGrid.php /pear/Structures_DataGrid/DataGrid/DataSource DataObject.php Log: fix bug #9147 and secure the sort direction string http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/DataGrid.php?r1=1.111&r2=1.112&diff_format=u Index: pear/Structures_DataGrid/DataGrid.php diff -u pear/Structures_DataGrid/DataGrid.php:1.111 pear/Structures_DataGrid/DataGrid.php:1.112 --- pear/Structures_DataGrid/DataGrid.php:1.111 Sat Oct 14 20:15:37 2006 +++ pear/Structures_DataGrid/DataGrid.php Tue Oct 24 15:29:11 2006 @@ -22,9 +22,9 @@ * +----------------------------------------------------------------------+ * </pre> * - * CSV file id: $Id: DataGrid.php,v 1.111 2006/10/14 20:15:37 wiesemann Exp $ + * CSV file id: $Id: DataGrid.php,v 1.112 2006/10/24 15:29:11 olivierg Exp $ * - * @version $Revision: 1.111 $ + * @version $Revision: 1.112 $ * @package Structures_DataGrid * @category Structures */ @@ -1248,7 +1248,19 @@ } return $value; } - + + /** + * Secure the sort direction string + * + * @param string $str Direction string + * @return string Either ASC or DESC + * @access private + */ + function _secureDirection($str) + { + return ($str == 'ASC' or $str == 'DESC') ? $str : 'ASC'; + } + /** * Parse HTTP Request parameters * @@ -1275,14 +1287,16 @@ $this->sortSpec = array(); foreach ($orderBy as $index => $field) { if (!empty($field)) { - $this->sortSpec[$field] = $direction[$index]; + $this->sortSpec[$field] = + $this->_secureDirection($direction[$index]); } } } else { if (!($direction = $this->_getRequestArgument('direction'))) { $direction = 'ASC'; } - $this->sortSpec = array($orderBy => $direction); + $this->sortSpec = + array($orderBy => $this->_secureDirection($direction)); } } } http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php?r1=1.34&r2=1.35&diff_format=u Index: pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php diff -u pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.34 pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.35 --- pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php:1.34 Sat Jul 8 16:44:22 2006 +++ pear/Structures_DataGrid/DataGrid/DataSource/DataObject.php Tue Oct 24 15:29:11 2006 @@ -21,9 +21,9 @@ * +----------------------------------------------------------------------+ * </pre> * - * CSV file id: $Id: DataObject.php,v 1.34 2006/07/08 16:44:22 wiesemann Exp $ + * CSV file id: $Id: DataObject.php,v 1.35 2006/10/24 15:29:11 olivierg Exp $ * - * @version $Revision: 1.34 $ + * @version $Revision: 1.35 $ * @package Structures_DataGrid_DataSource_DataObject * @category Structures */ @@ -51,7 +51,7 @@ * this one will not be used. * (default: 'fb_fieldsToRender') * - * @version $Revision: 1.34 $ + * @version $Revision: 1.35 $ * @author Olivier Guilyardi <olivier@samalyse.com> * @author Andrew Nagy <asnagy@webitecture.org> * @access public @@ -299,11 +299,15 @@ */ function sort($sortSpec, $sortDir = null) { + $db =& $this->_dataobject->getDatabaseConnection(); + if (is_array($sortSpec)) { foreach ($sortSpec as $field => $direction) { + $field = $db->quoteIdentifier($field); $this->_dataobject->orderBy("$field $direction"); } } else { + $sortSpec = $db->quoteIdentifier($sortSpec); if (is_null($sortDir)) { $this->_dataobject->orderBy($sortSpec); } else {

« previous php.pear.cvs (#42787) next »