voku / HtmlMin

:clamp: HtmlMin: HTML Compressor and Minifier via PHP
MIT License
161 stars 22 forks source link

Multiple <code> tags results in fatal error #27

Closed ozupey closed 5 years ago

ozupey commented 5 years ago

What is this feature about (expected vs actual behaviour)?

Having multiple <code> tags results in a fatal error.

Warning: Couldn't fetch DOMElement. Node no longer exists in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 485

Call Stack:
    0.0001     386032   1. {main}() scripts/test.php:0
    0.0240    2647432   2. voku\helper\HtmlMin->minify() scripts/test.php:7
    0.0241    2647616   3. voku\helper\HtmlMin->minifyHtmlDom() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1082
    0.0397    3298824   4. voku\helper\HtmlMin->protectTags() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1207
    0.0415    3397496   5. voku\helper\SimpleHtmlDom->parentNode() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1277

Notice: Undefined property: DOMElement::$parentNode in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 485

Call Stack:
    0.0001     386032   1. {main}() scripts/test.php:0
    0.0240    2647432   2. voku\helper\HtmlMin->minify() scripts/test.php:7
    0.0241    2647616   3. voku\helper\HtmlMin->minifyHtmlDom() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1082
    0.0397    3298824   4. voku\helper\HtmlMin->protectTags() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1207
    0.0415    3397496   5. voku\helper\SimpleHtmlDom->parentNode() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1277

Fatal error: Uncaught TypeError: Argument 1 passed to voku\helper\SimpleHtmlDom::__construct() must be an instance of DOMNode, null given, called in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 485 and defined in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 61

TypeError: Argument 1 passed to voku\helper\SimpleHtmlDom::__construct() must be an instance of DOMNode, null given, called in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 485 in vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php on line 61

Call Stack:
    0.0001     386032   1. {main}() scripts/test.php:0
    0.0240    2647432   2. voku\helper\HtmlMin->minify() scripts/test.php:7
    0.0241    2647616   3. voku\helper\HtmlMin->minifyHtmlDom() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1082
    0.0397    3298824   4. voku\helper\HtmlMin->protectTags() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1207
    0.0415    3397496   5. voku\helper\SimpleHtmlDom->parentNode() vendor/voku/html-min/src/voku/helper/HtmlMin.php:1277
    0.0461    3398192   6. voku\helper\SimpleHtmlDom->__construct() vendor/voku/simple_html_dom/src/voku/helper/SimpleHtmlDom.php:485

How can I reproduce it?

$html = '<code>foo</code> and <code>bar</code>';

$htmlMin = new voku\helper\HtmlMin();
$htmlMin->minify($html);

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.

voku commented 5 years ago

fixed in version 3.1.4