html5-dom-document-php
html5-dom-document-php copied to clipboard
Suggestions
Nice work. I have some suggestions.
https://github.com/ivopetkov/html5-dom-document-php/blob/3eccd3ca69bc7d0789d10c23638a4eab9fc4050d/src/HTML5DOMDocument.php#L371
I think this unintentionally trims newlines in the end where it isn't needed. I think your intent is to remove newline somehow added by the code before but it ends up cutting newlines elsewhere.
Another observation on this part:
https://github.com/ivopetkov/html5-dom-document-php/blob/3eccd3ca69bc7d0789d10c23638a4eab9fc4050d/src/HTML5DOMDocument.php#L159-L161
There is also an &#x type of entities. I am not sure of the following but you could check if the entity is really a genuine one or fake by doing something like
html_entity_decode( $matches[0], ENT_QUOTES, 'UTF-8' ) === $matches[0] )
with preg_replace_callback
Maybe not needed.
You could also add some random string every time in the "internal" string for security purposes, maybe I am saying something silly.