mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +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
|
||||
{
|
||||
$content = preg_replace_callback('#(@verbatim)\b(.+?)(@endverbatim)\b#s', function($match) {
|
||||
return preg_replace(['#(?<!@)\{\{#', '#(?<!@)@([a-z]+)#', '#\$#'], ['@{{', '@@$1', '$'], $match[2]);
|
||||
$conversions = [
|
||||
'#(?<!\{)\{(?!\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);
|
||||
return $content;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1015,6 +1015,7 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
|||
'@verbatim',
|
||||
'@if (true)',
|
||||
'<p>{{ $foobar }}</p>',
|
||||
'<p>{$foobar}</p>',
|
||||
'@endif',
|
||||
'@endverbatim',
|
||||
]);
|
||||
|
|
@ -1022,6 +1023,7 @@ class TemplateParserV2Test extends \Codeception\Test\Unit
|
|||
'',
|
||||
'@if (true)',
|
||||
'<p>{{ $foobar }}</p>',
|
||||
'<p>{$foobar}</p>',
|
||||
'@endif',
|
||||
'',
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue