HTML inside script tags is turned invalid
ozupey opened this issue · 4 comments
What is this feature about (expected vs actual behaviour)?
Any HTML that's inside a <script type=text/html>
tag is turned invalid. Similar to issue #26. Seems like voku/simple_html_dom@e6e597e#diff-c9aceb5e54e67d5f19805df3f679fb1bR389 only works on double quotes or single quotes (type="text/html"
or type='text/html'
) rather than no quotes at all (type=text/html
).
string(81) "<script type=text/html><p>Foo
<div class="alert alert-success">
Bar</script>"
How can I reproduce it?
$html = '
<script type=text/html>
<p>Foo</p>
<div class="alert alert-success">
Bar
</div>
</script>
';
$htmlMin = new voku\helper\HtmlMin();
$result = $htmlMin->minify($html);
var_dump($result);
Does it take minutes, hours or days to fix?
Unsure
Any additional information?
Using 3.1.3 installed via composer on PHP 7.2.10.
Thanks for the bug report, fixed in version 3.1.6
It looks like any occurrence of {{
will cancel minification.
It seems to be on purpose, but I'm not sure why: https://github.com/voku/simple_html_dom/blob/master/src/voku/helper/HtmlDomParser.php#L947
If I disable that line, it minifies just fine and I'm not seeing any negative effects.
<script type="text/html">
{{foo}}
{{bar}}
{{hello}}
</script>
Will result in:
string(63) "<script type=text/html> {{foo}}
{{bar}}
{{hello}}
</script>"
It would be nice if there was at least an option to force minification of these special tags, perhaps disabled by default. :)
Hi and thanks for the bug report (again) 👍 ... fixed in version 4.4.0. Here is an example: 9a88a5c#diff-468b8a043eb54ed31edbee53141c1512R769