- bugfix modification of 9.8.2017 did fail on some recursive

tag nesting. https://github.com/smarty-php/smarty/issues/389
This commit is contained in:
Uwe Tews
2017-10-07 08:40:28 +02:00
parent b0ea1cb5df
commit 428efa634d
5 changed files with 3770 additions and 2845 deletions

View File

@@ -0,0 +1,96 @@
<?php
/**
* Smarty Method GetLiterals
*
* Smarty::getLiterals() method
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Method_Literals
{
/**
* Valid for Smarty and template object
*
* @var int
*/
public $objMap = 3;
/**
* Get literals
*
* @api Smarty::getLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
*
* @return array list of literals
*/
public function getLiterals(Smarty_Internal_TemplateBase $obj)
{
$smarty = $obj->_getSmartyObj();
return (array)$smarty->literals;
}
/**
* Add literals
*
* @api Smarty::addLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to add
*
* @return \Smarty|\Smarty_Internal_Template
*/
public function addLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
{
if (isset($literals)) {
$this->set($obj->_getSmartyObj(), (array)$literals);
}
return $obj;
}
/**
* Set literals
*
* @api Smarty::setLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to set
*
* @return \Smarty|\Smarty_Internal_Template
*/
public function setLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
{
$smarty = $obj->_getSmartyObj();
$smarty->literals = array();
if (!empty($literals)) {
$this->set($smarty, (array)$literals);
}
return $obj;
}
/**
* common setter for literals for easier handling of duplicates the
* Smarty::$literals array gets filled with identical key values
*
* @param \Smarty $smarty
* @param array $literals
*
* @throws \SmartyException
*/
private function set(Smarty $smarty, $literals)
{
$literals = array_combine($literals, $literals);
$error = isset($literals[ $smarty->left_delimiter ]) ? array($smarty->left_delimiter) : array();
$error = isset($literals[ $smarty->right_delimiter ]) ? $error[] = $smarty->right_delimiter : $error;
if (!empty($error)) {
throw new SmartyException('User defined literal(s) "' . $error .
'" may not be identical with left or right delimiter');
}
$smarty->literals = array_merge((array)$smarty->literals, (array)$literals);
}
}

View File

@@ -21,10 +21,12 @@
*
* @method Smarty_Internal_TemplateBase addAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase addDefaultModifier(mixed $modifiers)
* @method Smarty_Internal_TemplateBase addLiterals(mixed $literals)
* @method Smarty_Internal_TemplateBase createData(Smarty_Internal_Data $parent = null, string $name = null)
* @method array getAutoloadFilters(string $type = null)
* @method string getDebugTemplate()
* @method array getDefaultModifier()
* @method array getLiterals()
* @method array getTags(mixed $template = null)
* @method object getRegisteredObject(string $object_name)
* @method Smarty_Internal_TemplateBase registerCacheResource(string $name, Smarty_CacheResource $resource_handler)
@@ -36,6 +38,7 @@
* @method Smarty_Internal_TemplateBase setAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase setDebugTemplate(string $tpl_name)
* @method Smarty_Internal_TemplateBase setDefaultModifiers(mixed $modifiers)
* @method Smarty_Internal_TemplateBase setLiterals(mixed $literals)
* @method Smarty_Internal_TemplateBase unloadFilter(string $type, string $name)
* @method Smarty_Internal_TemplateBase unregisterCacheResource(string $name)
* @method Smarty_Internal_TemplateBase unregisterObject(string $object_name)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -359,9 +359,13 @@ class Smarty_Internal_TestInstall
// test if sysplugins are available
$source = SMARTY_SYSPLUGINS_DIR;
if (is_dir($source)) {
$expectedSysplugins = array('smartycompilerexception.php' => true, 'smartyexception.php' => true,
'smarty_cacheresource.php' => true, 'smarty_cacheresource_custom.php' => true,
'smarty_cacheresource_keyvaluestore.php' => true, 'smarty_data.php' => true,
$expectedSysplugins = array(
'smartycompilerexception.php' => true,
'smartyexception.php' => true,
'smarty_cacheresource.php' => true,
'smarty_cacheresource_custom.php' => true,
'smarty_cacheresource_keyvaluestore.php' => true,
'smarty_data.php' => true,
'smarty_internal_block.php' => true,
'smarty_internal_cacheresource_file.php' => true,
'smarty_internal_compilebase.php' => true,
@@ -407,7 +411,8 @@ class Smarty_Internal_TestInstall
'smarty_internal_configfilelexer.php' => true,
'smarty_internal_configfileparser.php' => true,
'smarty_internal_config_file_compiler.php' => true,
'smarty_internal_data.php' => true, 'smarty_internal_debug.php' => true,
'smarty_internal_data.php' => true,
'smarty_internal_debug.php' => true,
'smarty_internal_extension_handler.php' => true,
'smarty_internal_method_addautoloadfilters.php' => true,
'smarty_internal_method_adddefaultmodifiers.php' => true,
@@ -435,6 +440,7 @@ class Smarty_Internal_TestInstall
'smarty_internal_method_getstreamvariable.php' => true,
'smarty_internal_method_gettags.php' => true,
'smarty_internal_method_gettemplatevars.php' => true,
'smarty_internal_method_literals.php' => true,
'smarty_internal_method_loadfilter.php' => true,
'smarty_internal_method_loadplugin.php' => true,
'smarty_internal_method_mustcompile.php' => true,
@@ -491,14 +497,20 @@ class Smarty_Internal_TestInstall
'smarty_internal_templatelexer.php' => true,
'smarty_internal_templateparser.php' => true,
'smarty_internal_testinstall.php' => true,
'smarty_internal_undefined.php' => true, 'smarty_resource.php' => true,
'smarty_resource_custom.php' => true, 'smarty_resource_recompiled.php' => true,
'smarty_resource_uncompiled.php' => true, 'smarty_security.php' => true,
'smarty_template_cached.php' => true, 'smarty_template_compiled.php' => true,
'smarty_internal_undefined.php' => true,
'smarty_resource.php' => true,
'smarty_resource_custom.php' => true,
'smarty_resource_recompiled.php' => true,
'smarty_resource_uncompiled.php' => true,
'smarty_security.php' => true,
'smarty_template_cached.php' => true,
'smarty_template_compiled.php' => true,
'smarty_template_config.php' => true,
'smarty_template_resource_base.php' => true,
'smarty_template_source.php' => true, 'smarty_undefined_variable.php' => true,
'smarty_variable.php' => true,);
'smarty_template_source.php' => true,
'smarty_undefined_variable.php' => true,
'smarty_variable.php' => true,
);
$iterator = new DirectoryIterator($source);
foreach ($iterator as $file) {
if (!$file->isDot()) {
@@ -535,30 +547,55 @@ class Smarty_Internal_TestInstall
// test if core plugins are available
$source = SMARTY_PLUGINS_DIR;
if (is_dir($source)) {
$expectedPlugins =
array('block.textformat.php' => true, 'function.counter.php' => true, 'function.cycle.php' => true,
'function.fetch.php' => true, 'function.html_checkboxes.php' => true,
'function.html_image.php' => true, 'function.html_options.php' => true,
'function.html_radios.php' => true, 'function.html_select_date.php' => true,
'function.html_select_time.php' => true, 'function.html_table.php' => true,
'function.mailto.php' => true, 'function.math.php' => true, 'modifier.capitalize.php' => true,
'modifier.date_format.php' => true, 'modifier.debug_print_var.php' => true,
'modifier.escape.php' => true, 'modifier.mb_wordwrap.php' => true,
'modifier.regex_replace.php' => true, 'modifier.replace.php' => true,
'modifier.spacify.php' => true, 'modifier.truncate.php' => true,
'modifiercompiler.cat.php' => true, 'modifiercompiler.count_characters.php' => true,
'modifiercompiler.count_paragraphs.php' => true, 'modifiercompiler.count_sentences.php' => true,
'modifiercompiler.count_words.php' => true, 'modifiercompiler.default.php' => true,
'modifiercompiler.escape.php' => true, 'modifiercompiler.from_charset.php' => true,
'modifiercompiler.indent.php' => true, 'modifiercompiler.lower.php' => true,
'modifiercompiler.noprint.php' => true, 'modifiercompiler.string_format.php' => true,
'modifiercompiler.strip.php' => true, 'modifiercompiler.strip_tags.php' => true,
'modifiercompiler.to_charset.php' => true, 'modifiercompiler.unescape.php' => true,
'modifiercompiler.upper.php' => true, 'modifiercompiler.wordwrap.php' => true,
'outputfilter.trimwhitespace.php' => true, 'shared.escape_special_chars.php' => true,
'shared.literal_compiler_param.php' => true, 'shared.make_timestamp.php' => true,
'shared.mb_str_replace.php' => true, 'shared.mb_unicode.php' => true,
'variablefilter.htmlspecialchars.php' => true,);
$expectedPlugins = array(
'block.textformat.php' => true,
'function.counter.php' => true,
'function.cycle.php' => true,
'function.fetch.php' => true,
'function.html_checkboxes.php' => true,
'function.html_image.php' => true,
'function.html_options.php' => true,
'function.html_radios.php' => true,
'function.html_select_date.php' => true,
'function.html_select_time.php' => true,
'function.html_table.php' => true,
'function.mailto.php' => true,
'function.math.php' => true,
'modifier.capitalize.php' => true,
'modifier.date_format.php' => true,
'modifier.debug_print_var.php' => true,
'modifier.escape.php' => true,
'modifier.mb_wordwrap.php' => true,
'modifier.regex_replace.php' => true,
'modifier.replace.php' => true,
'modifier.spacify.php' => true,
'modifier.truncate.php' => true,
'modifiercompiler.cat.php' => true,
'modifiercompiler.count_characters.php' => true,
'modifiercompiler.count_paragraphs.php' => true,
'modifiercompiler.count_sentences.php' => true,
'modifiercompiler.count_words.php' => true,
'modifiercompiler.default.php' => true,
'modifiercompiler.escape.php' => true,
'modifiercompiler.from_charset.php' => true,
'modifiercompiler.indent.php' => true,
'modifiercompiler.lower.php' => true,
'modifiercompiler.noprint.php' => true,
'modifiercompiler.string_format.php' => true,
'modifiercompiler.strip.php' => true,
'modifiercompiler.strip_tags.php' => true,
'modifiercompiler.to_charset.php' => true,
'modifiercompiler.unescape.php' => true,
'modifiercompiler.upper.php' => true,
'modifiercompiler.wordwrap.php' => true,
'outputfilter.trimwhitespace.php' => true,
'shared.escape_special_chars.php' => true,
'shared.literal_compiler_param.php' => true,
'shared.make_timestamp.php' => true,
'shared.mb_str_replace.php' => true,
'shared.mb_unicode.php' => true,
'variablefilter.htmlspecialchars.php' => true,
);
$iterator = new DirectoryIterator($source);
foreach ($iterator as $file) {
if (!$file->isDot()) {