Smarty 3.1.12 has been released.
3.1.12 has minor bug fixes and improvements. Smarty also received a security fix regarding the escapement of Smarty error messages. ie. an unrealistic but testable case where you call $smarty->display($_GET['id']); and the GET value is passed directly to the error message. To resolve any probable concern, error messages are now escaped. For details please read the Smarty 3.1.12 Change Log.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
Smarty 3.1.11
|
||||
Smarty 3.1.12
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -1,5 +1,49 @@
|
||||
===== trunk =====
|
||||
===== Smarty-3.1.11 =====
|
||||
===== Smarty-3.1.12 =====
|
||||
14.09.2012
|
||||
- bugfix template inheritance failed to compile with delimiters {/ and /} (Forum Topic 23008)
|
||||
|
||||
11.09.2012
|
||||
- bugfix escape Smarty exception messages to avoid possible script execution
|
||||
|
||||
10.09.2012
|
||||
- bugfix tag option flags and shorttag attributes did not work when rdel started with '=' (Forum Topic 22979)
|
||||
|
||||
31.08.2012
|
||||
- bugfix resolving relative paths broke in some circumstances (Issue #114)
|
||||
|
||||
22.08.2012
|
||||
- bugfix test MBString availability through mb_split, as it could've been compiled without regex support (--enable-mbregex).
|
||||
Either we get MBstring's full package, or we pretend it's not there at all.
|
||||
|
||||
21.08.2012
|
||||
- bugfix $auto_literal = false did not work with { block} tags in child templates
|
||||
(problem was reintroduced after fix in 3.1.7)(Forum Topic 20581)
|
||||
|
||||
17.08.2012
|
||||
- bugfix compiled code of nocache sections could contain wrong escaping (Forum Topic 22810)
|
||||
|
||||
15.08.2012
|
||||
- bugfix template inheritance did produce wrong code if subtemplates with {block} was
|
||||
included several times (from smarty-developers forum)
|
||||
|
||||
14.08.2012
|
||||
- bugfix PHP5.2 compatibility compromised by SplFileInfo::getBasename() (Issue 110)
|
||||
|
||||
01.08.2012
|
||||
- bugfix avoid PHP error on $smarty->configLoad(...) with invalid section specification (Forum Topic 22608)
|
||||
|
||||
30.07.2012
|
||||
-bugfix {assign} in a nocache section should not overwrite existing variable values
|
||||
during compilation (issue 109)
|
||||
|
||||
28.07.2012
|
||||
- bugfix array access of config variables did not work (Forum Topic 22527)
|
||||
|
||||
19.07.2012
|
||||
- bugfix the default plugin handler did create wrong compiled code for static class methods
|
||||
from external script files (issue 108)
|
||||
|
||||
===== Smarty-3.1.11 =====
|
||||
30.06.2012
|
||||
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: Smarty.class.php
|
||||
* SVN: $Id: Smarty.class.php 4614 2012-05-24 15:13:19Z rodneyrehm $
|
||||
* SVN: $Id: Smarty.class.php 4658 2012-09-11 16:23:30Z uwe.tews@googlemail.com $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -28,7 +28,7 @@
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
* @version 3.1-DEV
|
||||
* @version 3.1.12
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -57,7 +57,7 @@ if (!defined('SMARTY_PLUGINS_DIR')) {
|
||||
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
|
||||
}
|
||||
if (!defined('SMARTY_MBSTRING')) {
|
||||
define('SMARTY_MBSTRING', function_exists('mb_strlen'));
|
||||
define('SMARTY_MBSTRING', function_exists('mb_split'));
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
||||
// UTF-8 can only be done properly when mbstring is available!
|
||||
@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = 'Smarty-3.1.11';
|
||||
const SMARTY_VERSION = 'Smarty-3.1.12';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
@ -189,12 +189,12 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
* Flag denoting if PCRE should run in UTF-8 mode
|
||||
*/
|
||||
public static $_UTF8_MODIFIER = 'u';
|
||||
|
||||
|
||||
/**
|
||||
* Flag denoting if operating system is windows
|
||||
*/
|
||||
public static $_IS_WINDOWS = false;
|
||||
|
||||
|
||||
/**#@+
|
||||
* variables
|
||||
*/
|
||||
@ -1281,7 +1281,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
|
||||
|
||||
|
||||
$_stream_resolve_include_path = function_exists('stream_resolve_include_path');
|
||||
|
||||
// loop through plugin dirs and find the plugin
|
||||
@ -1302,7 +1302,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
} else {
|
||||
$file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
|
||||
}
|
||||
|
||||
|
||||
if ($file !== false) {
|
||||
require_once($file);
|
||||
return $file;
|
||||
@ -1481,6 +1481,9 @@ if (Smarty::$_CHARSET !== 'UTF-8') {
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyException extends Exception {
|
||||
public function __construct($message) {
|
||||
$this->message = htmlentities($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,10 +39,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.3.2 - prevent double encoding
|
||||
// php <5.2.3 - 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);
|
||||
@ -58,10 +58,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.3.2 - prevent double encoding
|
||||
// php <5.2.3 - 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);
|
||||
|
@ -57,7 +57,7 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
@ -65,7 +65,7 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
. '), "HTML-ENTITIES", '
|
||||
. var_export($char_set, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true)
|
||||
@ -78,13 +78,13 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
. var_export($double_encode, true) . ')';
|
||||
} else if ($double_encode) {
|
||||
// php <5.3.2 - only handle double encoding
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ')';
|
||||
|
@ -178,7 +178,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource {
|
||||
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($_cache as $_file) {
|
||||
if (substr($_file->getBasename(),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||
// directory ?
|
||||
if ($_file->isDir()) {
|
||||
if (!$_cache->isDot()) {
|
||||
|
@ -39,7 +39,11 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
|
||||
if ($compiler->tag_nocache || $compiler->nocache) {
|
||||
$_nocache = 'true';
|
||||
// create nocache var to make it know for further compiling
|
||||
$compiler->template->tpl_vars[trim($_attr['var'], "'")] = new Smarty_variable(null, true);
|
||||
if (isset($compiler->template->tpl_vars[trim($_attr['var'], "'")])) {
|
||||
$compiler->template->tpl_vars[trim($_attr['var'], "'")]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[trim($_attr['var'], "'")] = new Smarty_variable(null, true);
|
||||
}
|
||||
}
|
||||
// scope setup
|
||||
if (isset($_attr['scope'])) {
|
||||
|
@ -78,7 +78,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
public static function saveBlockData($block_content, $block_tag, $template, $filepath) {
|
||||
$_rdl = preg_quote($template->smarty->right_delimiter);
|
||||
$_ldl = preg_quote($template->smarty->left_delimiter);
|
||||
if ($template->smarty->auto_literal) {
|
||||
if (!$template->smarty->auto_literal) {
|
||||
$al = '\s*';
|
||||
} else {
|
||||
$al = '';
|
||||
@ -90,7 +90,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
$_name = trim($_match[3], '\'"');
|
||||
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
||||
// do we have {$smart.block.child} in nested {block} tags?
|
||||
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)) {
|
||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})([\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", $block_content, $_match2)) {
|
||||
foreach ($_match2[3] as $key => $name) {
|
||||
// get it's replacement
|
||||
$_name2 = trim($name, '\'"');
|
||||
@ -101,17 +101,17 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
$replacement = '';
|
||||
}
|
||||
// replace {$smarty.block.child} tag
|
||||
$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\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}/block\s*{$_rdl})!", "/<2F><><EFBFBD>child<6C><64><EFBFBD>/");
|
||||
$replace = array('\2<><32><EFBFBD>child<6C><64><EFBFBD>\4', $replacement);
|
||||
$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);
|
||||
$block_content = preg_replace("!({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", '', $block_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
// do we have not nested {$smart.block.child}
|
||||
if (0 != preg_match("/({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})/", $block_content, $_match2)) {
|
||||
if (0 != preg_match("!({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})!", $block_content, $_match2)) {
|
||||
// get child replacement for this block
|
||||
if (isset($template->block_data[$_name])) {
|
||||
$replacement = $template->block_data[$_name]['source'];
|
||||
@ -119,7 +119,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
} else {
|
||||
$replacement = '';
|
||||
}
|
||||
$block_content = preg_replace("/({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})/", $replacement, $block_content);
|
||||
$block_content = preg_replace("!({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})!", $replacement, $block_content);
|
||||
}
|
||||
if (isset($template->block_data[$_name])) {
|
||||
if (strpos($template->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
||||
|
@ -51,6 +51,11 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
$this->_rdl = preg_quote($compiler->smarty->right_delimiter);
|
||||
$this->_ldl = preg_quote($compiler->smarty->left_delimiter);
|
||||
if (!$compiler->smarty->auto_literal) {
|
||||
$al = '\s*';
|
||||
} else {
|
||||
$al = '';
|
||||
}
|
||||
$filepath = $compiler->template->source->filepath;
|
||||
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||
// check and get attributes
|
||||
@ -78,11 +83,11 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
|
||||
$_content = ($this->mbstring_overload ? mb_substr($compiler->template->source->content, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->template->source->content, $compiler->lex->counter - 1));
|
||||
if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
|
||||
preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
|
||||
if (preg_match_all("!({$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl})!", $_content, $s) !=
|
||||
preg_match_all("!({$this->_ldl}{$al}/block\s*{$this->_rdl})!", $_content, $c)) {
|
||||
$compiler->trigger_template_error('unmatched {block} {/block} pairs');
|
||||
}
|
||||
preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
|
||||
preg_match_all("!{$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl}|{$this->_ldl}{$al}/block\s*{$this->_rdl}|{$this->_ldl}\*([\S\s]*?)\*{$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
|
||||
$_result_count = count($_result[0]);
|
||||
$_start = 0;
|
||||
while ($_start+1 < $_result_count) {
|
||||
|
@ -80,7 +80,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
return '@' . trim($_index[1], "'");
|
||||
|
||||
case 'config':
|
||||
return "\$_smarty_tpl->getConfigVariable($_index[1])";
|
||||
if (isset($_index[2])) {
|
||||
return "(is_array(\$tmp = \$_smarty_tpl->getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||
} else {
|
||||
return "\$_smarty_tpl->getConfigVariable($_index[1])";
|
||||
}
|
||||
case 'ldelim':
|
||||
$_ldelim = $compiler->smarty->left_delimiter;
|
||||
return "'$_ldelim'";
|
||||
|
@ -240,9 +240,8 @@ class Smarty_Internal_Config {
|
||||
}
|
||||
// scan sections
|
||||
if (!empty($sections)) {
|
||||
$sections = array_flip((array) $sections);
|
||||
foreach ($_config_vars['sections'] as $this_section => $dummy) {
|
||||
if (isset($sections[$this_section])) {
|
||||
foreach ((array) $sections as $this_section) {
|
||||
if (isset($_config_vars['sections'][$this_section])) {
|
||||
foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
|
||||
if ($this->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
|
||||
$scope_ptr->config_vars[$variable] = $value;
|
||||
|
@ -89,6 +89,11 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
||||
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||
$_rdl = preg_quote($source->smarty->right_delimiter);
|
||||
$_ldl = preg_quote($source->smarty->left_delimiter);
|
||||
if (!$source->smarty->auto_literal) {
|
||||
$al = '\s*';
|
||||
} else {
|
||||
$al = '';
|
||||
}
|
||||
$_components = array_reverse($source->components);
|
||||
$_first = reset($_components);
|
||||
$_last = end($_components);
|
||||
@ -105,11 +110,11 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
||||
|
||||
// extend sources
|
||||
if ($_component != $_last) {
|
||||
if (preg_match_all("!({$_ldl}block\s(.+?){$_rdl})!", $_content, $_open) !=
|
||||
preg_match_all("!({$_ldl}/block{$_rdl})!", $_content, $_close)) {
|
||||
if (preg_match_all("!({$_ldl}{$al}block\s(.+?)\s*{$_rdl})!", $_content, $_open) !=
|
||||
preg_match_all("!({$_ldl}{$al}/block\s*{$_rdl})!", $_content, $_close)) {
|
||||
throw new SmartyException("unmatched {block} {/block} pairs in template {$_component->type} '{$_component->name}'");
|
||||
}
|
||||
preg_match_all("!{$_ldl}block\s(.+?){$_rdl}|{$_ldl}/block{$_rdl}|{$_ldl}\*([\S\s]*?)\*{$_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
|
||||
preg_match_all("!{$_ldl}{$al}block\s(.+?)\s*{$_rdl}|{$_ldl}{$al}/block\s*{$_rdl}|{$_ldl}\*([\S\s]*?)\*{$_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
|
||||
$_result_count = count($_result[0]);
|
||||
$_start = 0;
|
||||
while ($_start+1 < $_result_count) {
|
||||
|
@ -344,7 +344,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
foreach ($this->required_plugins['compiled'] as $tmp) {
|
||||
foreach ($tmp as $data) {
|
||||
$file = addslashes($data['file']);
|
||||
$plugins_string .= "if (!is_callable('{$data['function']}')) include '{$file}';\n";
|
||||
if (is_Array($data['function'])){
|
||||
$plugins_string .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) include '{$file}';\n";
|
||||
} else {
|
||||
$plugins_string .= "if (!is_callable('{$data['function']}')) include '{$file}';\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$plugins_string .= '?>';
|
||||
@ -355,7 +359,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
foreach ($this->required_plugins['nocache'] as $tmp) {
|
||||
foreach ($tmp as $data) {
|
||||
$file = addslashes($data['file']);
|
||||
$plugins_string .= addslashes("if (!is_callable('{$data['function']}')) include '{$file}';\n");
|
||||
if (is_Array($data['function'])){
|
||||
$plugins_string .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) include '{$file}';\n");
|
||||
} else {
|
||||
$plugins_string .= addslashes("if (!is_callable('{$data['function']}')) include '{$file}';\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
$plugins_string .= "?>/*/%%SmartyNocache:{$this->properties['nocache_hash']}%%*/';?>\n";
|
||||
|
@ -215,6 +215,8 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
} else {
|
||||
$code = $template_header . $template->createTemplateCodeFrame($_compiled_code) . $merged_code;
|
||||
}
|
||||
// unset content because template inheritance could have replace source with parent code
|
||||
unset ($template->source->content);
|
||||
return $code;
|
||||
}
|
||||
|
||||
@ -592,8 +594,7 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
if ((!($this->template->source->recompiled) || $this->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing &&
|
||||
($this->nocache || $this->tag_nocache || $this->forceNocache == 2)) {
|
||||
$this->template->has_nocache_code = true;
|
||||
$_output = str_replace("'", "\'", $content);
|
||||
$_output = str_replace('\\\\', '\\\\\\\\', $_output);
|
||||
$_output = addcslashes($content,'\'\\');
|
||||
$_output = str_replace("^#^", "'", $_output);
|
||||
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
||||
// make sure we include modifer plugins for nocache code
|
||||
|
@ -85,6 +85,7 @@ class Smarty_Internal_Templatelexer
|
||||
$this->ldel = preg_quote($this->smarty->left_delimiter,'/');
|
||||
$this->ldel_length = strlen($this->smarty->left_delimiter);
|
||||
$this->rdel = preg_quote($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['RDEL'] = $this->smarty->right_delimiter;
|
||||
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||
@ -141,11 +142,12 @@ class Smarty_Internal_Templatelexer
|
||||
21 => 0,
|
||||
22 => 0,
|
||||
23 => 0,
|
||||
24 => 0,
|
||||
);
|
||||
if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
$yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(".$this->rdel.")|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -344,16 +346,21 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r1_21($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
function yy_r1_22($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
|
||||
}
|
||||
function yy_r1_23($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
|
||||
}
|
||||
function yy_r1_24($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->mbstring_overload) {
|
||||
$to = mb_strlen($this->data,'latin1');
|
||||
} else {
|
||||
@ -447,7 +454,7 @@ class Smarty_Internal_Templatelexer
|
||||
if ($this->counter >= ($this->mbstring_overload ? mb_strlen($this->data,'latin1'): strlen($this->data))) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$this->rdel.")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s?=\\s?)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G([\S\s])/iS";
|
||||
$yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\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{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$this->rdel.")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*=\\s*)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, mb_substr($this->data, $this->counter,2000000000,'latin1'), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -853,7 +860,14 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r2_73($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ATTR;
|
||||
// resolve conflicts with shorttag and right_delimiter starting with '='
|
||||
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
|
||||
preg_match("/\s+/",$this->value,$match);
|
||||
$this->value = $match[0];
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ATTR;
|
||||
}
|
||||
}
|
||||
function yy_r2_74($yy_subpatterns)
|
||||
{
|
||||
@ -1187,4 +1201,3 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -72,7 +72,7 @@ class Smarty_Internal_Utility {
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs);
|
||||
foreach ($_compile as $_fileinfo) {
|
||||
if (substr($_fileinfo->getBasename(),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
$_file = $_fileinfo->getFilename();
|
||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||
@ -136,7 +136,7 @@ class Smarty_Internal_Utility {
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs);
|
||||
foreach ($_compile as $_fileinfo) {
|
||||
if (substr($_fileinfo->getBasename(),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
$_file = $_fileinfo->getFilename();
|
||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||
@ -231,7 +231,7 @@ class Smarty_Internal_Utility {
|
||||
}
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($_compile as $_file) {
|
||||
if (substr($_file->getBasename(), 0, 1) == '.' || strpos($_file, '.svn') !== false)
|
||||
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false)
|
||||
continue;
|
||||
|
||||
$_filepath = (string) $_file;
|
||||
|
@ -159,16 +159,18 @@ abstract class Smarty_Resource {
|
||||
$_path = str_replace('\\', '/', $_path);
|
||||
}
|
||||
|
||||
$offset = 0;
|
||||
|
||||
// resolve simples
|
||||
$_path = preg_replace('#(/\./(\./)*)|/{2,}#', '/', $_path);
|
||||
// resolve parents
|
||||
while (true) {
|
||||
$_parent = strpos($_path, '/../');
|
||||
if ($_parent === false) {
|
||||
break;
|
||||
} else if ($_parent === 0) {
|
||||
$_path = substr($_path, 3);
|
||||
$_parent = strpos($_path, '/../', $offset);
|
||||
if (!$_parent) {
|
||||
break;
|
||||
} else if ($_path[$_parent - 1] === '.') {
|
||||
$offset = $_parent + 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
$_pos = strrpos($_path, '/', $_parent - strlen($_path) - 1);
|
||||
@ -226,7 +228,6 @@ abstract class Smarty_Resource {
|
||||
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
|
||||
// don't we all just love windows?
|
||||
$_path = str_replace('\\', '/', $file);
|
||||
$_was_relative_prefix = $file[0] == '.' ? substr($file, 0, strpos($_path, '/')) : null;
|
||||
$_path = DS . trim($file, '/');
|
||||
$_was_relative = true;
|
||||
} else {
|
||||
@ -240,11 +241,7 @@ abstract class Smarty_Resource {
|
||||
}
|
||||
// revert to relative
|
||||
if (isset($_was_relative)) {
|
||||
if (isset($_was_relative_prefix)){
|
||||
$_path = $_was_relative_prefix . $_path;
|
||||
} else {
|
||||
$_path = substr($_path, 1);
|
||||
}
|
||||
$_path = substr($_path, 1);
|
||||
}
|
||||
|
||||
// this is only required for directories
|
||||
|
Reference in New Issue
Block a user