Skip to content

Commit

Permalink
- bugfix resolve naming conflict between custom Smarty delimiter '<%'…
Browse files Browse the repository at this point in the history
… and PHP ASP tags #64
  • Loading branch information
uwetews committed Jun 27, 2015
1 parent 3239a19 commit 9986286
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lexer/smarty_internal_templatelexer.plex
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ class Smarty_Internal_Templatelexer
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
all = ~[\S\s]+~
emptyjava = ~[{][}]~
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])|(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
phptag = ~(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])~
slash = ~[/]~
ldel = ~SMARTYldel\s*~
rdel = ~\s*SMARTYrdel~
Expand Down Expand Up @@ -331,6 +332,10 @@ class Smarty_Internal_Templatelexer
$this->value = substr($this->data,$this->counter,$to-$this->counter);
return false;
}
phptag {
$obj = new Smarty_Internal_Compile_Private_Php();
$obj->parsePhp($this);
}
ldel literal rdel {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
Expand Down
17 changes: 12 additions & 5 deletions libs/sysplugins/smarty_internal_templatelexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function yybegin($state)
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>])|(" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G([\S\s])/isS";
$this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
Expand Down Expand Up @@ -345,6 +345,13 @@ function yy_r1_2()
}

function yy_r1_3()
{

$obj = new Smarty_Internal_Compile_Private_Php();
$obj->parsePhp($this);
}

function yy_r1_7()
{

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

function yy_r1_4()
function yy_r1_8()
{

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

function yy_r1_5()
function yy_r1_9()
{

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

function yy_r1_6()
function yy_r1_10()
{

$obj = new Smarty_Internal_Compile_Private_Php();
$obj->parsePhp($this);
}

function yy_r1_18()
function yy_r1_19()
{

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

0 comments on commit 9986286

Please sign in to comment.