Removing closing tag within script tags
gijo-varghese opened this issue · 1 comments
gijo-varghese commented
<?php
$doc = new \DiDom\Document();
$doc->loadHTML('<html>
<head>
<script>
console.log("<h1>hello</h1>");
</script>
</head>
<body>
</body>
</html>');
echo $doc->html();
will result in
<html>
<head>
<script>
console.log("<h1>hello");
</script>
</head>
<body>
</body>
</html>
gijo-varghese commented
I fixed the issue by adding LIBXML_SCHEMA_CREATE
to the options, like $html->loadHTML($content, LIBXML_HTML_NODEFDTD | LIBXML_SCHEMA_CREATE);