mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
Fix #2272 unintended conversion of v1 echo statements inside verbatim section of v2 template
This commit is contained in:
parent
a0af57139e
commit
ee9a1a2b20
2 changed files with 11 additions and 2 deletions
|
|
@ -285,8 +285,15 @@ class TemplateParser_v2
|
||||||
*/
|
*/
|
||||||
protected function _convertVerbatimSections(string $content): string
|
protected function _convertVerbatimSections(string $content): string
|
||||||
{
|
{
|
||||||
$content = preg_replace_callback('#(@verbatim)\b(.+?)(@endverbatim)\b#s', function($match) {
|
$conversions = [
|
||||||
return preg_replace(['#(?<!@)\{\{#', '#(?<!@)@([a-z]+)#', '#\$#'], ['@{{', '@@$1', '$'], $match[2]);
|
'#(?<!\{)\{(?!\s)([^{}]+?)\}#' => '{$1}',
|
||||||
|
'#(?<!@)\{\{#' => '@{{',
|
||||||
|
'#(?<!@)@([a-z]+)#' => '@@$1',
|
||||||
|
'#\$#' => '$',
|
||||||
|
];
|
||||||
|
|
||||||
|
$content = preg_replace_callback('#(@verbatim)\b(.+?)(@endverbatim)\b#s', function($match) use($conversions) {
|
||||||
|
return preg_replace(array_keys($conversions), array_values($conversions), $match[2]);
|
||||||
}, $content);
|
}, $content);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1015,6 +1015,7 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
||||||
'@verbatim',
|
'@verbatim',
|
||||||
'@if (true)',
|
'@if (true)',
|
||||||
'<p>{{ $foobar }}</p>',
|
'<p>{{ $foobar }}</p>',
|
||||||
|
'<p>{$foobar}</p>',
|
||||||
'@endif',
|
'@endif',
|
||||||
'@endverbatim',
|
'@endverbatim',
|
||||||
]);
|
]);
|
||||||
|
|
@ -1022,6 +1023,7 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
||||||
'',
|
'',
|
||||||
'@if (true)',
|
'@if (true)',
|
||||||
'<p>{{ $foobar }}</p>',
|
'<p>{{ $foobar }}</p>',
|
||||||
|
'<p>{$foobar}</p>',
|
||||||
'@endif',
|
'@endif',
|
||||||
'',
|
'',
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue