-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
- bugfix on template inheritance when an {extends} tag was inserted by a prefilter
- 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
} 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;
}
$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);
}