You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a problem when I was creating a custom filter for XML files that escapes content in a CDATA block.
The problem is that I need the Latte parser to treat the returned value of this filter as already escaped (safe) text. In a HTML template everything works as expected. however when I use this filter in a XML template (specified using a {contentType xml} block), the returned value is always escaped by Latte no matter the selected ContentType in the filter.
Steps To Reproduce
$latte = new \Latte\Engine();
$latte->addFilter('cdata', staticfunction(\Latte\Runtime\FilterInfo$info, string$data) {
$info->contentType = \Latte\ContentType::Xml; // Same result with any other ContentTypereturn'<![CDATA[' . $data . ']]>';
});
$latte->setLoader(new \Latte\Loaders\StringLoader(['template' => '{contentType xml}<?xml version="1.0"?><root>{$foo|cdata}</root>']));
$latte->render('template', ['foo' => '<a>Hello world</a>']);
Version: 3.0.4
Bug Description
I have encountered a problem when I was creating a custom filter for XML files that escapes content in a CDATA block.
The problem is that I need the Latte parser to treat the returned value of this filter as already escaped (safe) text. In a HTML template everything works as expected. however when I use this filter in a XML template (specified using a
{contentType xml}
block), the returned value is always escaped by Latte no matter the selectedContentType
in the filter.Steps To Reproduce
Output:
<?xml version="1.0"?><root><![CDATA[<a>Hello world</a>]]></root>
(incorrect)Expected:
<?xml version="1.0"?><root><![CDATA[<a>Hello world</a>]]></root>
Expected Behavior
When used in a HTML template, everything works as expected. I would expect the same behaviour for XML templates.
The text was updated successfully, but these errors were encountered: