cvs: smarty / NEWS /libs Smarty_Compiler.class.php
"Messju Mohr" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmessju1088696375@cvsserver> |
messju Thu Jul 1 11:39:35 2004 EDT
Modified files:
/smarty NEWS
/smarty/libs Smarty_Compiler.class.php
Log:
enhanced error-reporting for {foreach}
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.458&r2=1.459&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.458 smarty/NEWS:1.459
--- smarty/NEWS:1.458 Thu Jul 1 08:20:43 2004
+++ smarty/NEWS Thu Jul 1 11:39:34 2004
@@ -1,3 +1,5 @@
+ - add error-messages when anything else than an identifier is passed
+ to foreach's key- or item-attribute (messju)
- fix handling of digits inside tagnames (messju)
- fix escaping of backslashes in Smarty_Compiler::_quote_replace() (messju)
http://cvs.php.net/diff.php/smarty/libs/Smarty_Compiler.class.php?r1=1.324&r2=1.325&ty=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.324 smarty/libs/Smarty_Compiler.class.php:1.325
--- smarty/libs/Smarty_Compiler.class.php:1.324 Thu Jul 1 08:20:43 2004
+++ smarty/libs/Smarty_Compiler.class.php Thu Jul 1 11:39:34 2004
@@ -26,7 +26,7 @@
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.324 2004/07/01 12:20:43 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.325 2004/07/01 15:39:34 messju Exp $ */
/**
* Template compiling class
@@ -1122,15 +1122,18 @@
$arg_list = array();
if (empty($attrs['from'])) {
- $this->_syntax_error("missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ $this->_syntax_error("foreach: missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__);
}
+ $from = $attrs['from'];
if (empty($attrs['item'])) {
- $this->_syntax_error("missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
+ $this->_syntax_error("foreach: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
}
-
- $from = $attrs['from'];
$item = $this->_dequote($attrs['item']);
+ if (!preg_match('!^\w+$!', $item)) {
+ $this->_syntax_error("'foreach: item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
+
if (isset($attrs['name']))
$name = $attrs['name'];
@@ -1146,6 +1149,9 @@
switch ($attr_name) {
case 'key':
$key = $this->_dequote($attrs['key']);
+ if (!preg_match('!^\w+$!', $key)) {
+ $this->_syntax_error("foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ }
$key_part = "\$this->_tpl_vars['$key'] => ";
break;
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php