-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageProxy: avoid oversight of wrapping an entire HTML document around image #212
Conversation
…d image In reply to <FreshRSS#206 (comment)>. With special thanks to this comment: <https://www.php.net/manual/en/domdocument.savehtml.php#119767>
Hm, I was just reading more and realized this may not be ideal, though at first glance the output looked okay:
|
I have not looked precisely, but a typical way is to |
That's the first thing I tried, as But I see what you're referring to is actually a for loop appending to a string. I had considered that, but it felt hacky. |
I think it makes a difference in behaviour to pass the node inside the |
And no, without loop. See e.g. |
Ah, in that case presumably it should simply be something like: $output = $dom->getElementsByTagName('body')->item(0);
return $dom->saveHTML($output); I'll test that tomorrow (if I find the time). PS Here are the other results. I hadn't notice the third was slightly different, whoops. |
For reference, this is the idea I played with first yesterday: $body = $doc->getElementsByTagName('body')->item(0);
$output = '';
foreach ($body->childNodes as $node) {
$output .= $doc->saveHTML($node);
}
return $output; The sample uses regex to effect the desired result. I will do so as well to limit new string creation. |
With the method in FreshRSS#212 undesired transformations could sometimes be effected.
* ImageProxy: better DOMDocument HTML handling With the method in #212 undesired transformations could sometimes be effected. * Update xExtension-ImageProxy/extension.php Co-authored-by: Alexandre Alapetite <[email protected]> * Bump version to 0.7.1 --------- Co-authored-by: Alexandre Alapetite <[email protected]>
In reply to #206 (comment).
With special thanks to this comment: https://www.php.net/manual/en/domdocument.savehtml.php#119767