- unclosed block tag in double quted string must throw compiler exception.

https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392
This commit is contained in:
Uwe Tews
2017-10-12 20:15:42 +02:00
parent b271173a2d
commit 6b97d5cdd5
7 changed files with 502 additions and 606 deletions

View File

@@ -2,6 +2,8 @@
12.10.2017 12.10.2017
- bugfix $smarty.block.child and $smarty.block.parent could not be used like any - bugfix $smarty.block.child and $smarty.block.parent could not be used like any
$smarty special variable https://github.com/smarty-php/smarty/issues/393 $smarty special variable https://github.com/smarty-php/smarty/issues/393
- unclosed block tag in double quoted string must throw compiler exception.
https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392
07.10.2017 07.10.2017
- bugfix modification of 9.8.2017 did fail on some recursive - bugfix modification of 9.8.2017 did fail on some recursive

View File

@@ -510,6 +510,7 @@ class Smarty_Internal_Templatelexer
double_quote { double_quote {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote();
} }
singlequotestring { singlequotestring {
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
@@ -693,6 +694,7 @@ class Smarty_Internal_Templatelexer
double_quote { double_quote {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();
$this->compiler->leaveDoubleQuote();
} }
backtick dollar { backtick dollar {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;

View File

@@ -135,7 +135,7 @@ class Smarty_Internal_Templateparser
public $template_prefix = array(); public $template_prefix = array();
/** /**
* security object * template prefix array
* *
* @var \Smarty_Internal_ParseTree[] * @var \Smarty_Internal_ParseTree[]
*/ */

View File

@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.32-dev-24'; const SMARTY_VERSION = '3.1.32-dev-25';
/** /**
* define variable scopes * define variable scopes

File diff suppressed because it is too large Load Diff

View File

@@ -243,7 +243,7 @@ class Smarty_Internal_Templatelexer
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
$this->counter = 0; $this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
$this->counter += strlen($match[0]); $this->counter += strlen($match[ 0 ]);
} }
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->smarty;
@@ -252,15 +252,14 @@ class Smarty_Internal_Templatelexer
$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->rdel_length = strlen($this->smarty->right_delimiter); $this->rdel_length = strlen($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;
$literals = $this->smarty->getLiterals(); $literals = $this->smarty->getLiterals();
if (!empty($literals)) { if (!empty($literals)) {
foreach ($literals as $key => $literal) { foreach ($literals as $key => $literal) {
$literals[ $key ] = preg_quote($literal, '/'); $literals[ $key ] = preg_quote($literal, '/');
} }
} }
if ($this->smarty->auto_literal) { if ($this->smarty->auto_literal) {
$literals[] = $this->ldel . '{1,}\\s+'; $literals[] = $this->ldel . '{1,}\\s+';
} }
@@ -374,10 +373,9 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
@@ -426,8 +424,8 @@ class Smarty_Internal_Templatelexer
function yy_r1_2() function yy_r1_2()
{ {
preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) { if (isset($match[ 0 ][ 1 ])) {
$to = $match[0][1] + strlen($match[0][0]); $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else { } else {
$this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'"); $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
} }
@@ -485,10 +483,9 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
@@ -618,10 +615,9 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
@@ -678,6 +674,7 @@ class Smarty_Internal_Templatelexer
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote();
} }
function yy_r3_4() function yy_r3_4()
@@ -816,7 +813,7 @@ class Smarty_Internal_Templatelexer
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
$this->smarty->right_delimiter) { $this->smarty->right_delimiter) {
preg_match("/\s+/", $this->value, $match); preg_match("/\s+/", $this->value, $match);
$this->value = $match[0]; $this->value = $match[ 0 ];
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $this->token = Smarty_Internal_Templateparser::TP_SPACE;
} else { } else {
$this->token = Smarty_Internal_Templateparser::TP_ATTR; $this->token = Smarty_Internal_Templateparser::TP_ATTR;
@@ -906,10 +903,9 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
@@ -989,10 +985,9 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) { if (!isset($yymatches[ 0 ][ 1 ])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches); $yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else { } else {
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
@@ -1071,6 +1066,7 @@ class Smarty_Internal_Templatelexer
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();
$this->compiler->leaveDoubleQuote();
} }
function yy_r5_8() function yy_r5_8()
@@ -1095,7 +1091,6 @@ class Smarty_Internal_Templatelexer
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
} }

File diff suppressed because it is too large Load Diff