act, array(\n'dispNmsAdminGroupList',\n'dispNmsAdminInsertGroup',\n'dispNmsAdminGroupInfo',\n'dispNmsAdminDeleteGroup'))){ ?>class=\"on\">"
),
// issue 746
array(
'
',
'?>
'
),
// issue 696
array(
'{@ eval(\'$val = $document_srl;\')}',
' eval(\'$__Context->val = $__Context->document_srl;\') ?>'
),
// https://github.com/xpressengine/xe-core/issues/1510
array(
'
',
'if($__Context->foo->bar ?? false){ ?>
'
),
// https://github.com/xpressengine/xe-core/issues/1510
array(
'
',
'if($__Context->foo->bar > 100){ ?>
'
),
// https://github.com/xpressengine/xe-core/issues/1510
array(
'
',
'if($__Context->foo->bar ?? false){ ?>
'
),
// https://github.com/xpressengine/xe-core/issues/1510
array(
'
',
'if(!$__Context->module_info->title){ ?>
'
),
// https://github.com/xpressengine/xe-core/issues/1510
array(
'
use" src="../img/common/blank.gif" />',
'if($__Context->mi->title ?? false){ ?>
mi->use){ ?> class="tmp_class" src="' . $this->baseurl . 'tests/_data/img/common/blank.gif" />'
),
array(
'
',
'?> foo->bar ?? false){ ?>
'
),
array(
'' . "\r\n" . '
',
'?>' . "\n" . ' foo->bar ?? false){ ?>
'
),
array(
'asf
',
'?>asf
'
),
array(
'
',
'?>
'
),
array(
'asdf src="../img/img.gif" asdf
asdf src="../img/img.gif" asdf',
'?>asdf src="../img/img.gif" asdf
asdf src="../img/img.gif" asdf'
),
array(
'asdf src="../img/img.gif" asdf',
'?>asdf src="../img/img.gif" asdf'
),
array(
'
',
'?>
'
),
// srcset (PR #1544)
array(
'
',
'?>
'
),
// Rhymix improvements (PR #604)
array(
'{$_SERVER["REMOTE_ADDR"]}',
'?>'
),
array(
'{escape($_COOKIE[$var], false)}',
'?>var], false) ?>'
),
array(
'{$GLOBALS[$__Context->rhymix->rules]}',
'?>rhymix->rules] ?>'
),
array(
'{$FOOBAR}',
'?>FOOBAR ?? \'\' ?>'
),
array(
'{RX_BASEDIR}',
'?>{RX_BASEDIR}'
),
array(
'{\RX_BASEDIR}',
'?>'
),
// Rhymix improvements: object attributes enclosed in curly braces
array(
'{$foo->$bar[$bazz]}
',
'?>foo->{$__Context->bar}[$__Context->bazz] ?>
'
),
array(
'',
'if($__Context->foo->{$__Context->bar}){ ?>'
),
array(
'',
'if($__Context->foo->{$__Context->bar}){ ?>'
),
array(
'',
'$__loop_tmp=$__Context->foo->{$__Context->bar};if($__loop_tmp)foreach($__loop_tmp as $__Context->key=>$__Context->val){ ?>foo->{$__Context->key}){ ?> class="test">- val ?? \'\' ?>
'
),
// Rhymix autoescape
array(
'{$foo}',
'$this->config->autoescape = true; ' . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo ?? \'\')) ?>'
),
array(
'{$foo}',
'$this->config->autoescape = false; ' . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo ?? \'\')) ?>'
),
array(
'{$foo|auto}',
'$this->config->autoescape = true; ' . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo ?? \'\')) ?>'
),
array(
'{$foo->$bar|auto}',
'$this->config->autoescape = false; ' . 'echo ($this->config->autoescape ? htmlspecialchars($__Context->foo->{$__Context->bar}, ENT_QUOTES, \'UTF-8\', false) : ($__Context->foo->{$__Context->bar})) ?>'
),
array(
'{$foo|autoescape}',
'$this->config->autoescape = true; ' . 'echo htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', false) ?>'
),
array(
'{$foo|autoescape}',
'$this->config->autoescape = false; ' . 'echo htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', false) ?>'
),
array(
'{$foo|escape}',
'$this->config->autoescape = true; ' . 'echo htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', true) ?>'
),
array(
'{$foo|escape}',
'$this->config->autoescape = false; ' . 'echo htmlspecialchars($__Context->foo ?? \'\', ENT_QUOTES, \'UTF-8\', true) ?>'
),
array(
'{$foo|noescape}',
'$this->config->autoescape = true; ' . 'echo $__Context->foo ?? \'\' ?>'
),
array(
'{$foo|noescape}',
'$this->config->autoescape = false; ' . 'echo $__Context->foo ?? \'\' ?>'
),
// Rhymix filters
array(
'{$foo|escape}
',
'?>foo ?? \'\', ENT_QUOTES, \'UTF-8\', true) ?>
'
),
array(
'{$foo|json}
',
'?>foo) ?>
'
),
array(
'{$foo|urlencode}
',
'?>foo) ?>
'
),
array(
'{$foo|lower|nl2br}
',
'?>foo)) ?>
'
),
array(
'{$foo|join:/|upper}
',
'?>foo)) ?>
'
),
array(
'{$foo|join:\||upper}
',
'?>foo)) ?>
'
),
array(
'{$foo|join:$separator}
',
'?>separator, $__Context->foo) ?>
'
),
array(
'{$foo|strip}
',
'?>foo) ?>
'
),
array(
'{$foo|strip:
}
',
'?>foo, \'
\') ?>
'
),
array(
'{$foo|strip:$mytags}
',
'?>foo, $__Context->mytags) ?>
'
),
array(
'{$foo|strip:myfunc($mytags)}
',
'?>foo, myfunc($__Context->mytags)) ?>
'
),
array(
'{$foo|trim|date}
',
'?>foo)), \'Y-m-d H:i:s\') ?>
'
),
array(
'{$foo|date:His}
',
'?>foo), \'His\') ?>
'
),
array(
'{$foo|format:2}
',
'?>foo, \'2\') ?>
'
),
array(
'{$foo->$bar|shorten}
',
'?>foo->{$__Context->bar}) ?>
'
),
array(
'{$foo|shorten:2}
',
'?>foo, \'2\') ?>
'
),
array(
'{$foo|date:His}
',
'?>foo), \'His\') ?>
'
),
array(
'{$foo[$bar]|link}
',
'?>foo[$__Context->bar]) . \'">\' . ($__Context->foo[$__Context->bar]) . \'\' ?>
'
),
array(
'{$foo|link:http://www.rhymix.org}
',
'?>\' . ($__Context->foo ?? \'\') . \'\' ?>
'
),
array(
'{$foo|link:$url}
',
'?>url ?? \'\') . \'">\' . ($__Context->foo ?? \'\') . \'\' ?>
'
),
array(
'{$foo|link:$url}
',
'$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(
'{$foo|dafuq}
',
'?>'
),
array(
'{$foo|4}
',
'?>foo|4 ?>
'
),
array(
'{$foo|a+7|lower}
',
'?>foo|a+7) ?>
'
),
array(
'{$foo|Filter}
',
'?>foo|Filter ?>
'
),
array(
'{$foo|filter++}
',
'?>foo|filter++ ?>
'
),
array(
'{$foo|filter:}
',
'?>foo|filter: ?>
'
),
array(
'{$foo|$bar}
',
'?>foo|$__Context->bar ?>
'
),
array(
'{$foo||bar}
',
'?>foo||bar ?>
'
),
array(
'{htmlspecialchars($var, ENT_COMPAT | ENT_HTML401)}
',
'?>var, ENT_COMPAT | ENT_HTML401) ?>
'
),
array(
'{$foo | $bar}
',
'?>foo | $__Context->bar ?>
'
),
);
foreach ($tests as $test)
{
$tmpl = new \Rhymix\Framework\Template('./tests/_data/template', 'empty.html');
$result = $tmpl->parse($test[0]);
$between = str_starts_with($test[1], '?>') ? '' : ' ';
$this->assertEquals($this->prefix . $between . $test[1], $result);
}
}
public function testParseNoContent()
{
$tmpl = new \Rhymix\Framework\Template('./tests/_data/template', 'empty.html');
$result = $tmpl->parse(null);
$this->assertEquals('', $result);
}
public function testCompileDirect()
{
$tmpl = new \Rhymix\Framework\Template();
$result = $tmpl->compileDirect('./tests/_data/template', 'v1example.html');
$result = trim($result);
$this->assertEquals($this->prefix . ' if($__Context->has_blog ?? false){ ?>Taggon\'s blog'.PHP_EOL.'', $result);
}
}