mirror of
https://github.com/smarty-php/smarty.git
synced 2025-07-31 16:37:14 +02:00
Fixed second param of unescape modifier.\nFixes #777
This commit is contained in:
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
- Fixed problems with smarty_mb_str_replace [#549](https://github.com/smarty-php/smarty/issues/549)
|
||||
- Fixed second parameter of unescape modifier not working [#777](https://github.com/smarty-php/smarty/issues/777)
|
||||
|
||||
### Changed
|
||||
- Updated HTML of the debug template [#599](https://github.com/smarty-php/smarty/pull/599)
|
||||
|
@@ -14,20 +14,28 @@
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params)
|
||||
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 'html';
|
||||
}
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_literal_compiler_param',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[ 2 ] = "'{$params[ 2 ]}'";
|
||||
}
|
||||
switch (trim($params[ 1 ], '"\'')) {
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
|
@@ -63,6 +63,11 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty
|
||||
$tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"url"}');
|
||||
$this->assertEquals($result, $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
public function testCharset()
|
||||
{
|
||||
$tpl = $this->smarty->createTemplate("string:{''Stiff Opposition Expected to Casketless Funeral Plan''|unescape:'htmlall':'utf-8'}");
|
||||
$this->assertEquals("'Stiff Opposition Expected to Casketless Funeral Plan'", $this->smarty->fetch($tpl));
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
Reference in New Issue
Block a user