tijsverkoyen / CssToInlineStyles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very usefull when you're sending emails.
BSD 3-Clause "New" or "Revised" License
5.8k stars 187 forks source link

Null documentElement handling #214

Open bytestream opened 3 years ago

bytestream commented 3 years ago

documentElement on the DOMDocument class can be either DocumentElement|null as noted at https://www.php.net/manual/en/class.domdocument.php

https://github.com/tijsverkoyen/CssToInlineStyles/blob/f4f37098456b0801ee1de84214bbc83078ae3c63/src/CssToInlineStyles.php#L137 doesn't correctly handle when documentElement returns NULL resulting in:

Argument 1 passed to DOMNode::removeChild() must be an instance of DOMNode, null given 

Given valid HTML input, this is noticeable in libxml 2.9.12 due to a bug in libxml https://gitlab.gnome.org/GNOME/libxml2/-/issues/318