mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
enhanced error-reporting for {foreach}
This commit is contained in:
2
NEWS
2
NEWS
@@ -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 handling of digits inside tagnames (messju)
|
||||||
- fix escaping of backslashes in Smarty_Compiler::_quote_replace() (messju)
|
- fix escaping of backslashes in Smarty_Compiler::_quote_replace() (messju)
|
||||||
|
|
||||||
|
@@ -1122,15 +1122,18 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$arg_list = array();
|
$arg_list = array();
|
||||||
|
|
||||||
if (empty($attrs['from'])) {
|
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'])) {
|
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__);
|
||||||
|
}
|
||||||
|
$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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
$from = $attrs['from'];
|
|
||||||
$item = $this->_dequote($attrs['item']);
|
|
||||||
if (isset($attrs['name']))
|
if (isset($attrs['name']))
|
||||||
$name = $attrs['name'];
|
$name = $attrs['name'];
|
||||||
|
|
||||||
@@ -1146,6 +1149,9 @@ class Smarty_Compiler extends Smarty {
|
|||||||
switch ($attr_name) {
|
switch ($attr_name) {
|
||||||
case 'key':
|
case 'key':
|
||||||
$key = $this->_dequote($attrs['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'] => ";
|
$key_part = "\$this->_tpl_vars['$key'] => ";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user