-bugfix allow integer as attribute name in plugin calls

-change  trimm whitespace from error message, removed long list of expected tokens
This commit is contained in:
uwe.tews@googlemail.com
2010-11-23 23:36:16 +00:00
parent c0130d5d34
commit c08664e75e
3 changed files with 21 additions and 14 deletions

View File

@@ -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 22/11/2010
- bugfix on template inheritance when an {extends} tag was inserted by a prefilter - bugfix on template inheritance when an {extends} tag was inserted by a prefilter
- added error message for illegal variable file attributes at {extends...} tags - added error message for illegal variable file attributes at {extends...} tags

View File

@@ -71,7 +71,8 @@ class Smarty_Internal_CompileBase {
} }
// must be named attribute // must be named attribute
} else { } else {
$_indexed_attr = array_merge($_indexed_attr, $mixed); reset($mixed);
$_indexed_attr[key($mixed)] = $mixed[key($mixed)];
} }
} }
} }

View File

@@ -401,24 +401,26 @@ class Smarty_Internal_TemplateCompilerBase {
$line = $this->lex->line; $line = $this->lex->line;
} }
$match = preg_split("/\n/", $this->lex->data); $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)) { if (isset($args)) {
// individual error message // individual error message
$error_text .= $args; $error_text .= $args;
} else { } else {
// expected token from parser // expected token from parser
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { $error_text .= ' - Unexpected "' . $this->lex->value.'"';
$exp_token = $this->parser->yyTokenName[$token]; if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4 ) {
if (isset($this->lex->smarty_token_names[$exp_token])) { foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
// token type from lexer $exp_token = $this->parser->yyTokenName[$token];
$expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"'; if (isset($this->lex->smarty_token_names[$exp_token])) {
} else { // token type from lexer
// otherwise internal token name $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
$expect[] = $this->parser->yyTokenName[$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 .= ', expected one of: ' . implode(' , ', $expect);
}
} }
throw new SmartyCompilerException($error_text); throw new SmartyCompilerException($error_text);
} }