diff --git a/change_log.txt b/change_log.txt index 6f6bf2ae..627eebd8 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,7 @@ +23/11/2011 +-bugfix allow integer as attribute name in plugin calls +-change trimm whitespace from error message, removed long list of expected tokens + 22/11/2010 - bugfix on template inheritance when an {extends} tag was inserted by a prefilter - added error message for illegal variable file attributes at {extends...} tags diff --git a/libs/sysplugins/smarty_internal_compilebase.php b/libs/sysplugins/smarty_internal_compilebase.php index 5b3260a2..6418acce 100644 --- a/libs/sysplugins/smarty_internal_compilebase.php +++ b/libs/sysplugins/smarty_internal_compilebase.php @@ -71,7 +71,8 @@ class Smarty_Internal_CompileBase { } // must be named attribute } else { - $_indexed_attr = array_merge($_indexed_attr, $mixed); + reset($mixed); + $_indexed_attr[key($mixed)] = $mixed[key($mixed)]; } } } diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 0470ec4c..38d612e0 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -401,24 +401,26 @@ class Smarty_Internal_TemplateCompilerBase { $line = $this->lex->line; } $match = preg_split("/\n/", $this->lex->data); - $error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . htmlspecialchars($match[$line-1]) . '" '; + $error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . htmlspecialchars(trim(preg_replace('![\t\r\n]+!',' ',$match[$line-1]))) . '" '; if (isset($args)) { // individual error message $error_text .= $args; } else { // expected token from parser - foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { - $exp_token = $this->parser->yyTokenName[$token]; - if (isset($this->lex->smarty_token_names[$exp_token])) { - // token type from lexer - $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; - } else { - // otherwise internal token name - $expect[] = $this->parser->yyTokenName[$token]; - } - } - // output parser error message - $error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect); + $error_text .= ' - Unexpected "' . $this->lex->value.'"'; + if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4 ) { + foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { + $exp_token = $this->parser->yyTokenName[$token]; + if (isset($this->lex->smarty_token_names[$exp_token])) { + // token type from lexer + $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; + } else { + // otherwise internal token name + $expect[] = $this->parser->yyTokenName[$token]; + } + } + $error_text .= ', expected one of: ' . implode(' , ', $expect); + } } throw new SmartyCompilerException($error_text); }