diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php
index fa7fcb9c3..ed233dcf6 100644
--- a/classes/template/TemplateHandler.class.php
+++ b/classes/template/TemplateHandler.class.php
@@ -263,7 +263,7 @@ class TemplateHandler
$this->config = new stdClass();
// detect existence of autoescape config
- $this->config->autoescape = (strpos($buff, ' autoescape="') === FALSE) ? NULL : 'off';
+ $this->config->autoescape = (strpos($buff, ' autoescape="') === false) ? null : false;
// replace comments
$buff = preg_replace('@@s', '', $buff);
@@ -970,7 +970,8 @@ class TemplateHandler
{
foreach($config_matches as $config_match)
{
- $result .= "\$this->config->{$config_match[1]} = '" . trim(strtolower($config_match[2])) . "';";
+ $config_value = toBool(trim(strtolower($config_match[2]))) ? 'true' : 'false';
+ $result .= "\$this->config->{$config_match[1]} = $config_value;";
}
}
return "";
@@ -1042,7 +1043,7 @@ class TemplateHandler
return "(preg_match('/^\\$(?:user_)?lang->[a-zA-Z0-9\_]+$/', {$str}) ? ({$str}) : htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', false))";
case 'auto':
default:
- return "(\$this->config->autoescape === 'on' ? htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', false) : ({$str}))";
+ return "(\$this->config->autoescape ? htmlspecialchars({$str}, ENT_QUOTES, 'UTF-8', false) : ({$str}))";
}
}
diff --git a/tests/unit/classes/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php
index 7a6a8f3e8..42f06be47 100644
--- a/tests/unit/classes/TemplateHandlerTest.php
+++ b/tests/unit/classes/TemplateHandlerTest.php
@@ -328,43 +328,43 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
// Rhymix autoescape
array(
'{$foo}',
- PHP_EOL . '$this->config->autoescape = \'on\';' . "\n" . 'echo ($this->config->autoescape === \'on\' ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
+ PHP_EOL . '$this->config->autoescape = true;' . "\n" . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
),
array(
'{$foo}',
- PHP_EOL . '$this->config->autoescape = \'off\';' . "\n" . 'echo ($this->config->autoescape === \'on\' ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
+ PHP_EOL . '$this->config->autoescape = false;' . "\n" . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
),
array(
- '{$foo|auto}',
- PHP_EOL . '$this->config->autoescape = \'on\';' . "\n" . 'echo ($this->config->autoescape === \'on\' ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
+ '{$foo|auto}',
+ PHP_EOL . '$this->config->autoescape = true;' . "\n" . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
),
array(
- '{$foo|auto}',
- PHP_EOL . '$this->config->autoescape = \'off\';' . "\n" . 'echo ($this->config->autoescape === \'on\' ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) ?>'
+ '{$foo->$bar|auto}',
+ PHP_EOL . '$this->config->autoescape = false;' . "\n" . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo->{$__Context->bar}, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo->{$__Context->bar})) ?>'
),
array(
- '{$foo|autoescape}',
- PHP_EOL . '$this->config->autoescape = \'on\';' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) ?>'
+ '{$foo|autoescape}',
+ PHP_EOL . '$this->config->autoescape = true;' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) ?>'
),
array(
- '{$foo|autoescape}',
- PHP_EOL . '$this->config->autoescape = \'off\';' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) ?>'
+ '{$foo|autoescape}',
+ PHP_EOL . '$this->config->autoescape = false;' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) ?>'
),
array(
- '{$foo|escape}',
- PHP_EOL . '$this->config->autoescape = \'on\';' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', true) ?>'
+ '{$foo|escape}',
+ PHP_EOL . '$this->config->autoescape = true;' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', true) ?>'
),
array(
- '{$foo|escape}',
- PHP_EOL . '$this->config->autoescape = \'off\';' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', true) ?>'
+ '{$foo|escape}',
+ PHP_EOL . '$this->config->autoescape = false;' . "\n" . 'echo htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', true) ?>'
),
array(
- '{$foo|noescape}',
- PHP_EOL . '$this->config->autoescape = \'on\';' . "\n" . 'echo $__Context->foo ?>'
+ '{$foo|noescape}',
+ PHP_EOL . '$this->config->autoescape = true;' . "\n" . 'echo $__Context->foo ?>'
),
array(
- '{$foo|noescape}',
- PHP_EOL . '$this->config->autoescape = \'off\';' . "\n" . 'echo $__Context->foo ?>'
+ '{$foo|noescape}',
+ PHP_EOL . '$this->config->autoescape = false;' . "\n" . 'echo $__Context->foo ?>'
),
// Rhymix filters
array(
@@ -449,7 +449,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
),
array(
'
{$foo|link:$url}
',
- PHP_EOL . '$this->config->autoescape = \'on\'; ?>config->autoescape === \'on\' ? htmlspecialchars($__Context->url, ENT_QUOTES, \'UTF-8\', false) : ($__Context->url)) . \'">\' . ($this->config->autoescape === \'on\' ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) . \'\' ?>
'
+ PHP_EOL . '$this->config->autoescape = true; ?>config->autoescape ? htmlspecialchars($__Context->url, ENT_QUOTES, \'UTF-8\', false) : ($__Context->url)) . \'">\' . ($this->config->autoescape ? htmlspecialchars($__Context->foo, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo)) . \'\' ?>
'
),
// Rhymix filters (reject malformed filters)
array(