Skip to content

Commit

Permalink
allow use of text/plain for script tag (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
lubomirblazekcz authored and dg committed Feb 22, 2022
1 parent 76e0f60 commit 4f1ff80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Latte/Compiler/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ private function processHtmlTagEnd(Token $token): void

} elseif (
(($lower = strtolower($htmlNode->name)) === 'script' || $lower === 'style')
&& (!isset($htmlNode->attrs['type']) || preg_match('#(java|j|ecma|live)script|module|json|css#i', $htmlNode->attrs['type']))
&& (!isset($htmlNode->attrs['type']) || preg_match('#(java|j|ecma|live)script|module|json|css|plain#i', $htmlNode->attrs['type']))
) {
$this->context = $lower === 'script'
? self::CONTEXT_HTML_JS
Expand Down
5 changes: 5 additions & 0 deletions tests/common/contentType.html.javascript.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ Assert::match(
$latte->renderToString('<script type="module">{="<>"}')
);

Assert::match(
'<script type="text/plain">"<>"',
$latte->renderToString('<script type="text/plain">{="<>"}')
);

Assert::match(
'<script type="application/json">{ foo:"<>" }',
$latte->renderToString('<script type="application/json">{ foo:{="<>"} }')
Expand Down

0 comments on commit 4f1ff80

Please sign in to comment.