Smarty 3.1.11
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
Smarty 3.1.10
|
Smarty 3.1.11
|
||||||
|
|
||||||
Author: Monte Ohrt <monte at ohrt dot com >
|
Author: Monte Ohrt <monte at ohrt dot com >
|
||||||
Author: Uwe Tews
|
Author: Uwe Tews
|
||||||
|
@@ -1,4 +1,18 @@
|
|||||||
===== Smarty-3.1.10 =====
|
===== trunk =====
|
||||||
|
===== Smarty-3.1.11 =====
|
||||||
|
30.06.2012
|
||||||
|
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||||
|
|
||||||
|
25.06.2012
|
||||||
|
- bugfix the default plugin handler did not allow static class methods for modifier (issue 85)
|
||||||
|
|
||||||
|
24.06.2012
|
||||||
|
- bugfix escape modifier support for PHP < 5.2.3 (Forum Topic 21176)
|
||||||
|
|
||||||
|
11.06.2012
|
||||||
|
- bugfix the patch for Topic 21856 did break tabs between tag attributes (Forum Topic 22124)
|
||||||
|
|
||||||
|
===== Smarty-3.1.10 =====
|
||||||
09.06.2012
|
09.06.2012
|
||||||
- bugfix the compiler did ignore registered compiler plugins for closing tags (Forum Topic 22094)
|
- bugfix the compiler did ignore registered compiler plugins for closing tags (Forum Topic 22094)
|
||||||
- bugfix the patch for Topic 21856 did break multiline tags (Forum Topic 22124)
|
- bugfix the patch for Topic 21856 did break multiline tags (Forum Topic 22124)
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @version 3.1.10
|
* @version 3.1-DEV
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = 'Smarty-3.1.10';
|
const SMARTY_VERSION = 'Smarty-3.1.11';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -23,24 +23,69 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||||
{
|
{
|
||||||
|
static $_double_encode = null;
|
||||||
|
if ($_double_encode === null) {
|
||||||
|
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||||
|
}
|
||||||
|
|
||||||
if (!$char_set) {
|
if (!$char_set) {
|
||||||
$char_set = Smarty::$_CHARSET;
|
$char_set = Smarty::$_CHARSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
|
if ($_double_encode) {
|
||||||
|
// php >=5.3.2 - go native
|
||||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
|
} else {
|
||||||
|
if ($double_encode) {
|
||||||
|
// php <5.3.2 - only handle double encoding
|
||||||
|
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
} else {
|
||||||
|
// php <5.3.2 - prevent double encoding
|
||||||
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
// mb_convert_encoding ignores htmlspecialchars()
|
// mb_convert_encoding ignores htmlspecialchars()
|
||||||
|
if ($_double_encode) {
|
||||||
|
// php >=5.3.2 - go native
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
|
} else {
|
||||||
|
if ($double_encode) {
|
||||||
|
// php <5.3.2 - only handle double encoding
|
||||||
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
} else {
|
||||||
|
// php <5.3.2 - prevent double encoding
|
||||||
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
|
if ($_double_encode) {
|
||||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
|
} else {
|
||||||
|
if ($double_encode) {
|
||||||
|
return htmlentities($string, ENT_QUOTES, $char_set);
|
||||||
|
} else {
|
||||||
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
|
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||||
|
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return rawurlencode($string);
|
return rawurlencode($string);
|
||||||
|
@@ -25,6 +25,11 @@ require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' );
|
|||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_escape($params, $compiler)
|
function smarty_modifiercompiler_escape($params, $compiler)
|
||||||
{
|
{
|
||||||
|
static $_double_encode = null;
|
||||||
|
if ($_double_encode === null) {
|
||||||
|
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||||
@@ -36,26 +41,56 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
|||||||
|
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
|
if ($_double_encode) {
|
||||||
return 'htmlspecialchars('
|
return 'htmlspecialchars('
|
||||||
. $params[0] .', ENT_QUOTES, '
|
. $params[0] .', ENT_QUOTES, '
|
||||||
. var_export($char_set, true) . ', '
|
. var_export($char_set, true) . ', '
|
||||||
. var_export($double_encode, true) . ')';
|
. var_export($double_encode, true) . ')';
|
||||||
|
} else if ($double_encode) {
|
||||||
|
return 'htmlspecialchars('
|
||||||
|
. $params[0] .', ENT_QUOTES, '
|
||||||
|
. var_export($char_set, true) . ')';
|
||||||
|
} else {
|
||||||
|
// fall back to modifier.escape.php
|
||||||
|
}
|
||||||
|
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
|
if ($_double_encode) {
|
||||||
|
// php >=5.3.2 - go native
|
||||||
return 'mb_convert_encoding(htmlspecialchars('
|
return 'mb_convert_encoding(htmlspecialchars('
|
||||||
. $params[0] .', ENT_QUOTES, '
|
. $params[0] .', ENT_QUOTES, '
|
||||||
. var_export($char_set, true) . ', '
|
. var_export($char_set, true) . ', '
|
||||||
. var_export($double_encode, true)
|
. var_export($double_encode, true)
|
||||||
. '), "HTML-ENTITIES", '
|
. '), "HTML-ENTITIES", '
|
||||||
. var_export($char_set, true) . ')';
|
. var_export($char_set, true) . ')';
|
||||||
|
} else if ($double_encode) {
|
||||||
|
// php <5.3.2 - only handle double encoding
|
||||||
|
return 'mb_convert_encoding(htmlspecialchars('
|
||||||
|
. $params[0] .', ENT_QUOTES, '
|
||||||
|
. var_export($char_set, true)
|
||||||
|
. '), "HTML-ENTITIES", '
|
||||||
|
. var_export($char_set, true) . ')';
|
||||||
|
} else {
|
||||||
|
// fall back to modifier.escape.php
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
|
if ($_double_encode) {
|
||||||
|
// php >=5.3.2 - go native
|
||||||
return 'htmlentities('
|
return 'htmlentities('
|
||||||
. $params[0] .', ENT_QUOTES, '
|
. $params[0] .', ENT_QUOTES, '
|
||||||
. var_export($char_set, true) . ', '
|
. var_export($char_set, true) . ', '
|
||||||
. var_export($double_encode, true) . ')';
|
. var_export($double_encode, true) . ')';
|
||||||
|
} else if ($double_encode) {
|
||||||
|
// php <5.3.2 - only handle double encoding
|
||||||
|
return 'htmlentities('
|
||||||
|
. $params[0] .', ENT_QUOTES, '
|
||||||
|
. var_export($char_set, true) . ')';
|
||||||
|
} else {
|
||||||
|
// fall back to modifier.escape.php
|
||||||
|
}
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return 'rawurlencode(' . $params[0] . ')';
|
return 'rawurlencode(' . $params[0] . ')';
|
||||||
|
@@ -40,6 +40,7 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Strip all HTML-Comments
|
// Strip all HTML-Comments
|
||||||
|
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
||||||
$source = preg_replace( '#<!--.*?-->#ms', '', $source );
|
$source = preg_replace( '#<!--.*?-->#ms', '', $source );
|
||||||
|
|
||||||
// capture html elements not to be messed with
|
// capture html elements not to be messed with
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Block
|
* Smarty Internal Plugin Compile Block
|
||||||
*
|
*
|
||||||
@@ -24,6 +25,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('name');
|
public $required_attributes = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -31,6 +33,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('name', 'hide');
|
public $shorttag_order = array('name', 'hide');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -46,8 +49,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler) {
|
||||||
{
|
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
|
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
|
||||||
@@ -73,8 +75,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $template template object
|
* @param object $template template object
|
||||||
* @param string $filepath filepath of template source
|
* @param string $filepath filepath of template source
|
||||||
*/
|
*/
|
||||||
public static function saveBlockData($block_content, $block_tag, $template, $filepath)
|
public static function saveBlockData($block_content, $block_tag, $template, $filepath) {
|
||||||
{
|
|
||||||
$_rdl = preg_quote($template->smarty->right_delimiter);
|
$_rdl = preg_quote($template->smarty->right_delimiter);
|
||||||
$_ldl = preg_quote($template->smarty->left_delimiter);
|
$_ldl = preg_quote($template->smarty->left_delimiter);
|
||||||
if ($template->smarty->auto_literal) {
|
if ($template->smarty->auto_literal) {
|
||||||
@@ -89,10 +90,11 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$_name = trim($_match[3], '\'"');
|
$_name = trim($_match[3], '\'"');
|
||||||
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
||||||
// do we have {$smart.block.child} in nested {block} tags?
|
// do we have {$smart.block.child} in nested {block} tags?
|
||||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})!", $block_content, $_match2)) {
|
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})!", $block_content, $_match2)) {
|
||||||
foreach($_match2[3] as $name) {
|
foreach ($_match2[3] as $key => $name) {
|
||||||
// get it's replacement
|
// get it's replacement
|
||||||
$_name2 = trim($name, '\'"');
|
$_name2 = trim($name, '\'"');
|
||||||
|
if ($_match2[5][$key] != 'hide' || isset($template->block_data[$_name2])) {
|
||||||
if (isset($template->block_data[$_name2])) {
|
if (isset($template->block_data[$_name2])) {
|
||||||
$replacement = $template->block_data[$_name2]['source'];
|
$replacement = $template->block_data[$_name2]['source'];
|
||||||
} else {
|
} else {
|
||||||
@@ -102,6 +104,10 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$search = array("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?)({$_ldl}{$al}/block{$_rdl})%", "/<2F><><EFBFBD>child<6C><64><EFBFBD>/");
|
$search = array("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?)({$_ldl}{$al}/block{$_rdl})%", "/<2F><><EFBFBD>child<6C><64><EFBFBD>/");
|
||||||
$replace = array('\2<><32><EFBFBD>child<6C><64><EFBFBD>\4', $replacement);
|
$replace = array('\2<><32><EFBFBD>child<6C><64><EFBFBD>\4', $replacement);
|
||||||
$block_content = preg_replace($search, $replace, $block_content);
|
$block_content = preg_replace($search, $replace, $block_content);
|
||||||
|
} else {
|
||||||
|
// remove hidden blocks
|
||||||
|
$block_content = preg_replace("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl}[\s\S]*?{$_ldl}{$al}/block{$_rdl})%", '', $block_content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do we have not nested {$smart.block.child}
|
// do we have not nested {$smart.block.child}
|
||||||
@@ -146,8 +152,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param string $_name optional name of child block
|
* @param string $_name optional name of child block
|
||||||
* @return string compiled code of schild block
|
* @return string compiled code of schild block
|
||||||
*/
|
*/
|
||||||
public static function compileChildBlock($compiler, $_name = null)
|
public static function compileChildBlock($compiler, $_name = null) {
|
||||||
{
|
|
||||||
$_output = '';
|
$_output = '';
|
||||||
// if called by {$smarty.block.child} we must search the name of enclosing {block}
|
// if called by {$smarty.block.child} we must search the name of enclosing {block}
|
||||||
if ($_name == null) {
|
if ($_name == null) {
|
||||||
@@ -231,8 +236,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler) {
|
||||||
{
|
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
@@ -108,7 +108,15 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
|
||||||
// check if modifier allowed
|
// check if modifier allowed
|
||||||
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
|
||||||
|
if (!is_array($function)) {
|
||||||
$output = "{$function}({$params})";
|
$output = "{$function}({$params})";
|
||||||
|
} else {
|
||||||
|
if (is_object($function[0])) {
|
||||||
|
$output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||||
|
} else {
|
||||||
|
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
|
if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
|
||||||
// was a plugin
|
// was a plugin
|
||||||
|
Reference in New Issue
Block a user