15/09/2010

- bugfix resolving conflict between '<%'/'%>' as custom Smarty delimiter and ASP tags
- use ucfirst for resource name on internal resource class names
This commit is contained in:
uwe.tews@googlemail.com
2010-09-15 15:17:28 +00:00
parent 4556f7d370
commit 44c6732970
4 changed files with 2892 additions and 2883 deletions

View File

@@ -1,3 +1,7 @@
15/09/2010
- bugfix resolving conflict between '<%'/'%>' as custom Smarty delimiter and ASP tags
- use ucfirst for resource name on internal resource class names
12/09/2010 12/09/2010
- bugfix for change of 08/09/2010 (final {block} tags in subtemplates did not produce correct results) - bugfix for change of 08/09/2010 (final {block} tags in subtemplates did not produce correct results)

View File

@@ -713,11 +713,11 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
} else { } else {
// try sysplugins dir // try sysplugins dir
if (in_array($resource_type, array('file', 'string', 'extends', 'php', 'registered', 'stream'))) { if (in_array($resource_type, array('file', 'string', 'extends', 'php', 'registered', 'stream'))) {
$_resource_class = 'Smarty_Internal_Resource_' . $resource_type; $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($resource_type);
return new $_resource_class($this->smarty); return new $_resource_class($this->smarty);
} else { } else {
// try plugins dir // try plugins dir
$_resource_class = 'Smarty_Resource_' . $resource_type; $_resource_class = 'Smarty_Resource_' . ucfirst($resource_type);
if ($this->smarty->loadPlugin($_resource_class)) { if ($this->smarty->loadPlugin($_resource_class)) {
if (class_exists($_resource_class, false)) { if (class_exists($_resource_class, false)) {
return new $_resource_class($this->smarty); return new $_resource_class($this->smarty);

View File

@@ -1,16 +1,15 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templatelexer * Smarty Internal Plugin Templatelexer
* *
* This is the lexer to break the template source into tokens * This is the lexer to break the template source into tokens
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @author Uwe Tews * @author Uwe Tews
*/ */
/** /**
* Smarty Internal Plugin Templatelexer * Smarty Internal Plugin Templatelexer
*/ */
class Smarty_Internal_Templatelexer class Smarty_Internal_Templatelexer
{ {
public $data; public $data;
@@ -23,61 +22,61 @@ class Smarty_Internal_Templatelexer
public $state = 1; public $state = 1;
public $strip = false; public $strip = false;
private $heredoc_id_stack = Array(); private $heredoc_id_stack = Array();
public $smarty_token_names = array ( // Text for parser error messages public $smarty_token_names = array ( // Text for parser error messages
'IDENTITY' => '===', 'IDENTITY' => '===',
'NONEIDENTITY' => '!==', 'NONEIDENTITY' => '!==',
'EQUALS' => '==', 'EQUALS' => '==',
'NOTEQUALS' => '!=', 'NOTEQUALS' => '!=',
'GREATEREQUAL' => '(>=,ge)', 'GREATEREQUAL' => '(>=,ge)',
'LESSEQUAL' => '(<=,le)', 'LESSEQUAL' => '(<=,le)',
'GREATERTHAN' => '(>,gt)', 'GREATERTHAN' => '(>,gt)',
'LESSTHAN' => '(<,lt)', 'LESSTHAN' => '(<,lt)',
'MOD' => '(%,mod)', 'MOD' => '(%,mod)',
'NOT' => '(!,not)', 'NOT' => '(!,not)',
'LAND' => '(&&,and)', 'LAND' => '(&&,and)',
'LOR' => '(||,or)', 'LOR' => '(||,or)',
'LXOR' => 'xor', 'LXOR' => 'xor',
'OPENP' => '(', 'OPENP' => '(',
'CLOSEP' => ')', 'CLOSEP' => ')',
'OPENB' => '[', 'OPENB' => '[',
'CLOSEB' => ']', 'CLOSEB' => ']',
'PTR' => '->', 'PTR' => '->',
'APTR' => '=>', 'APTR' => '=>',
'EQUAL' => '=', 'EQUAL' => '=',
'NUMBER' => 'number', 'NUMBER' => 'number',
'UNIMATH' => '+" , "-', 'UNIMATH' => '+" , "-',
'MATH' => '*" , "/" , "%', 'MATH' => '*" , "/" , "%',
'INCDEC' => '++" , "--', 'INCDEC' => '++" , "--',
'SPACE' => ' ', 'SPACE' => ' ',
'DOLLAR' => '$', 'DOLLAR' => '$',
'SEMICOLON' => ';', 'SEMICOLON' => ';',
'COLON' => ':', 'COLON' => ':',
'DOUBLECOLON' => '::', 'DOUBLECOLON' => '::',
'AT' => '@', 'AT' => '@',
'HATCH' => '#', 'HATCH' => '#',
'QUOTE' => '"', 'QUOTE' => '"',
'BACKTICK' => '`', 'BACKTICK' => '`',
'VERT' => '|', 'VERT' => '|',
'DOT' => '.', 'DOT' => '.',
'COMMA' => '","', 'COMMA' => '","',
'ANDSYM' => '"&"', 'ANDSYM' => '"&"',
'QMARK' => '"?"', 'QMARK' => '"?"',
'ID' => 'identifier', 'ID' => 'identifier',
'OTHER' => 'text', 'OTHER' => 'text',
'LINEBREAK' => 'newline', 'LINEBREAK' => 'newline',
'FAKEPHPSTARTTAG' => 'Fake PHP start tag', 'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
'PHPSTARTTAG' => 'PHP start tag', 'PHPSTARTTAG' => 'PHP start tag',
'PHPENDTAG' => 'PHP end tag', 'PHPENDTAG' => 'PHP end tag',
'LITERALSTART' => 'Literal start', 'LITERALSTART' => 'Literal start',
'LITERALEND' => 'Literal end', 'LITERALEND' => 'Literal end',
'LDELSLASH' => 'closing tag', 'LDELSLASH' => 'closing tag',
'COMMENT' => 'comment', 'COMMENT' => 'comment',
'LITERALEND' => 'literal close', 'LITERALEND' => 'literal close',
'AS' => 'as', 'AS' => 'as',
'TO' => 'to', 'TO' => 'to',
); );
function __construct($data,$compiler) function __construct($data,$compiler)
{ {
// set instance object // set instance object
@@ -91,8 +90,8 @@ class Smarty_Internal_Templatelexer
$this->ldel = preg_quote($this->smarty->left_delimiter,'/'); $this->ldel = preg_quote($this->smarty->left_delimiter,'/');
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter,'/'); $this->rdel = preg_quote($this->smarty->right_delimiter,'/');
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
} }
public static function &instance($new_instance = null) public static function &instance($new_instance = null)
{ {
@@ -142,11 +141,11 @@ class Smarty_Internal_Templatelexer
8 => 0, 8 => 0,
9 => 0, 9 => 0,
10 => 0, 10 => 0,
11 => 0, 11 => 1,
12 => 0,
13 => 0, 13 => 0,
14 => 0, 14 => 0,
15 => 1, 15 => 0,
16 => 0,
17 => 0, 17 => 0,
18 => 0, 18 => 0,
19 => 0, 19 => 0,
@@ -158,7 +157,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= strlen($this->data)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
} }
$yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)/"; $yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)/";
do { do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) { if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -221,46 +220,19 @@ class Smarty_Internal_Templatelexer
function yy_r1_4($yy_subpatterns) function yy_r1_4($yy_subpatterns)
{ {
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
} elseif ($this->value == '<?xml') {
$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
} else {
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
$this->value = substr($this->value, 0, 2);
}
}
function yy_r1_5($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
}
function yy_r1_6($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
}
function yy_r1_7($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
}
function yy_r1_8($yy_subpatterns)
{
if ($this->strip) { if ($this->strip) {
return false; return false;
} else { } else {
$this->token = Smarty_Internal_Templateparser::TP_LINEBREAK; $this->token = Smarty_Internal_Templateparser::TP_LINEBREAK;
} }
} }
function yy_r1_9($yy_subpatterns) function yy_r1_5($yy_subpatterns)
{ {
$this->strip = true; $this->strip = true;
return false; return false;
} }
function yy_r1_10($yy_subpatterns) function yy_r1_6($yy_subpatterns)
{ {
if ($this->smarty->auto_literal) { if ($this->smarty->auto_literal) {
@@ -270,13 +242,13 @@ class Smarty_Internal_Templatelexer
return false; return false;
} }
} }
function yy_r1_11($yy_subpatterns) function yy_r1_7($yy_subpatterns)
{ {
$this->strip = false; $this->strip = false;
return false; return false;
} }
function yy_r1_12($yy_subpatterns) function yy_r1_8($yy_subpatterns)
{ {
if ($this->smarty->auto_literal) { if ($this->smarty->auto_literal) {
@@ -286,13 +258,13 @@ class Smarty_Internal_Templatelexer
return false; return false;
} }
} }
function yy_r1_13($yy_subpatterns) function yy_r1_9($yy_subpatterns)
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} }
function yy_r1_14($yy_subpatterns) function yy_r1_10($yy_subpatterns)
{ {
if ($this->smarty->auto_literal) { if ($this->smarty->auto_literal) {
@@ -303,7 +275,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} }
function yy_r1_15($yy_subpatterns) function yy_r1_11($yy_subpatterns)
{ {
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
@@ -314,7 +286,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} }
function yy_r1_17($yy_subpatterns) function yy_r1_13($yy_subpatterns)
{ {
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
@@ -325,7 +297,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} }
function yy_r1_18($yy_subpatterns) function yy_r1_14($yy_subpatterns)
{ {
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') { if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
@@ -336,7 +308,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} }
function yy_r1_19($yy_subpatterns) function yy_r1_15($yy_subpatterns)
{ {
if ($this->smarty->auto_literal) { if ($this->smarty->auto_literal) {
@@ -347,20 +319,47 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} }
function yy_r1_20($yy_subpatterns) function yy_r1_16($yy_subpatterns)
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yypushstate(self::SMARTY); $this->yypushstate(self::SMARTY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r1_21($yy_subpatterns) function yy_r1_17($yy_subpatterns)
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yypushstate(self::SMARTY); $this->yypushstate(self::SMARTY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r1_18($yy_subpatterns)
{
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
} elseif ($this->value == '<?xml') {
$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
} else {
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
$this->value = substr($this->value, 0, 2);
}
}
function yy_r1_19($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
}
function yy_r1_20($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
}
function yy_r1_21($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
}
function yy_r1_22($yy_subpatterns) function yy_r1_22($yy_subpatterns)
{ {
@@ -973,7 +972,7 @@ class Smarty_Internal_Templatelexer
function yy_r3_5($yy_subpatterns) function yy_r3_5($yy_subpatterns)
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
} }
function yy_r3_6($yy_subpatterns) function yy_r3_6($yy_subpatterns)
{ {

File diff suppressed because it is too large Load Diff