Skip to content

Commit

Permalink
- bugfix {php}{/php} did work just for single lines #33
Browse files Browse the repository at this point in the history
  • Loading branch information
uwetews committed May 16, 2015
1 parent 9f1061f commit a74804b
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 171 deletions.
2 changes: 1 addition & 1 deletion change_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- display Smarty version number
- Truncate lenght of Origin display and extend strin value display to 80 character
- bugfix in Smarty_Security 'nl2br' should be a trusted modifier, not PHP function (code.google issue 223)
- bugfix template functions failed when calling the function recursively with function name as tag name https://github.com/smarty-php/smarty/issues/35
- bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33

12.05.2015
- bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28
Expand Down
8 changes: 4 additions & 4 deletions lexer/smarty_internal_templatelexer.plex
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ class Smarty_Internal_Templatelexer
all = /[\S\s]+/
emptyjava = /\{\}/
xmltag = /<\?xml\s+([\S\s]*?)\?>/
php = /(<\?(?:php\s+|=)?)((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)\?>/
phpscript = /<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)<\/script>/
phptag = /(SMARTYldel\s*php\s*(.)*?SMARTYrdel((.)*?)SMARTYldel\s*\/php\s*SMARTYrdel)|(SMARTYldel\s*[\/]?php\s*(.)*?SMARTYrdel)/
asp = /<%((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)%>/
php = /(<\?(?:php\s+|=)?)((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*[\S\s]*?\*\/)|[\S\s])*?)\?>/
phpscript = /<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*[\S\s]*?\*\/)|[\S\s])*?)<\/script>/
phptag = /(SMARTYldel\s*php\s*(.)*?SMARTYrdel([\S\s]*?)SMARTYldel\s*\/php\s*SMARTYrdel)|(SMARTYldel\s*[\/]?php\s*(.)*?SMARTYrdel)/
asp = /<%((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*[\S\s]*?\*\/)|[\S\s])*?)%>/
unmatched = /(<(\?(?:php\s+|=)?|(script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)|%))|\?>|%>/
slash = /\//
ldel = /SMARTYldel\s*/
Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.24-dev/4';
const SMARTY_VERSION = '3.1.24-dev/5';

/**
* define variable scopes
Expand Down
22 changes: 11 additions & 11 deletions libs/sysplugins/smarty_internal_templatelexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ public function yybegin($state)

public function yylex1()
{
$tokenMap = array(1 => 0, 2 => 1, 4 => 0, 5 => 0, 6 => 0, 7 => 1, 9 => 0, 10 => 0, 11 => 0, 12 => 6, 19 => 0, 20 => 0, 21 => 0, 22 => 1, 24 => 6, 31 => 7, 39 => 6, 46 => 3, 50 => 0,);
$tokenMap = array(1 => 0, 2 => 1, 4 => 0, 5 => 0, 6 => 0, 7 => 1, 9 => 0, 10 => 0, 11 => 0, 12 => 5, 18 => 0, 19 => 0, 20 => 0, 21 => 1, 23 => 5, 29 => 6, 36 => 5, 42 => 3, 46 => 0,);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G((" . $this->ldel . "\\s*php\\s*(.)*?" . $this->rdel . "((.)*?)" . $this->ldel . "\\s*\/php\\s*" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]?php\\s*(.)*?" . $this->rdel . "))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G(<\\?xml\\s+([\S\s]*?)\\?>)|\G(<%((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)%>)|\G((<\\?(?:php\\s+|=)?)((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)\\?>)|\G(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*(.)*?\\*\/)|.)*?)<\/script>)|\G((<(\\?(?:php\\s+|=)?|(script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|%))|\\?>|%>)|\G([\S\s])/iS";
$yy_global_pattern = "/\G(\\{\\})|\G(" . $this->ldel . "\\*([\S\s]*?)\\*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G((" . $this->ldel . "\\s*php\\s*(.)*?" . $this->rdel . "([\S\s]*?)" . $this->ldel . "\\s*\/php\\s*" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]?php\\s*(.)*?" . $this->rdel . "))|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G(<\\?xml\\s+([\S\s]*?)\\?>)|\G(<%((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*[\S\s]*?\\*\/)|[\S\s])*?)%>)|\G((<\\?(?:php\\s+|=)?)((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*[\S\s]*?\\*\/)|[\S\s])*?)\\?>)|\G(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>((('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")|(\/\\*[\S\s]*?\\*\/)|[\S\s])*?)<\/script>)|\G((<(\\?(?:php\\s+|=)?|(script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|%))|\\?>|%>)|\G([\S\s])/iS";

do {
if (preg_match($yy_global_pattern, $this->data, $yymatches, null, $this->counter)) {
Expand Down Expand Up @@ -386,7 +386,7 @@ function yy_r1_12($yy_subpatterns)
}
}

function yy_r1_19($yy_subpatterns)
function yy_r1_18($yy_subpatterns)
{

if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
Expand All @@ -398,7 +398,7 @@ function yy_r1_19($yy_subpatterns)
}
}

function yy_r1_20($yy_subpatterns)
function yy_r1_19($yy_subpatterns)
{

if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
Expand All @@ -410,52 +410,52 @@ function yy_r1_20($yy_subpatterns)
}
}

function yy_r1_21($yy_subpatterns)
function yy_r1_20($yy_subpatterns)
{

$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}

function yy_r1_22($yy_subpatterns)
function yy_r1_21($yy_subpatterns)
{

$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
$this->taglineno = $this->line;
}

function yy_r1_24($yy_subpatterns)
function yy_r1_23($yy_subpatterns)
{

$this->phpType = 'asp';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}

function yy_r1_31($yy_subpatterns)
function yy_r1_29($yy_subpatterns)
{

$this->phpType = 'php';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}

function yy_r1_39($yy_subpatterns)
function yy_r1_36($yy_subpatterns)
{

$this->phpType = 'script';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}

function yy_r1_46($yy_subpatterns)
function yy_r1_42($yy_subpatterns)
{

$this->phpType = 'unmatched';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}

function yy_r1_50($yy_subpatterns)
function yy_r1_46($yy_subpatterns)
{

$to = strlen($this->data);
Expand Down
Loading

0 comments on commit a74804b

Please sign in to comment.