php-html-parser icon indicating copy to clipboard operation
php-html-parser copied to clipboard

incorrectly closing html comments

Open danslo opened this issue 3 years ago • 4 comments

See the following example:

<?php

require "vendor/autoload.php";

use PHPHtmlParser\Dom;
use PHPHtmlParser\Options;

$options = new Options();
$options->setCleanupInput(false);

$dom = new Dom();
$dom->setOptions($options);

$dom->loadStr('<!--<div><img />-->');
echo $dom->__toString();

No DOM manipulation was done, just loading string and immediately printing it.

Output is:

<!--<div--><img />-->

Expected output is:

<!--<div><img />-->

danslo avatar Mar 19 '21 10:03 danslo

I assume this has to do with the change in 3.1.1:

Comment tags are now self-closing when cleanup input is set to false.

But that does not seem like proper behavior to me.

danslo avatar Mar 19 '21 10:03 danslo

I have come across this as well. Can confirm that the bug appeared in 3.1.1. Also, this issue looks like a duplicate of #258.

aleksip avatar Jul 15 '21 14:07 aleksip

confirm this bug still exists, seem to happen when a "/" is inside a comment.

AlexanderKoe avatar Sep 30 '21 10:09 AlexanderKoe

Please see the mentioned commit for a fix. Also the package is now available with additional tweaks on packagist.

EreMaijala avatar Oct 10 '22 14:10 EreMaijala