From 5bbd299c7e3d38ffc6d3e618054ca288f947a203 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Wed, 16 Jul 2025 16:44:10 -0700 Subject: Call DOMNode::insertBefore() on the parent of it's $child (#7741) Follow-up to https://github.com/FreshRSS/FreshRSS/pull/7654#discussion_r2208901108 Changes proposed in this pull request: - `DOMNode::insertBefore()` needs to be called on an element that is the parent of the `$child` param being passed - Update code to call this on `$doc->documentElement` instead of directly on the `$doc` (`DOMDocument`) How to test the feature manually: 1. Set up an HTML + XPath feed for a URL that contains partial HTML content (eg. https://victoria.citified.ca/modules/blog/news.php?n=7&c=8) 1. Observe that the feed is processed successfully without error, and that the `` is still inserted --- lib/lib_rss.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 196ab06a4..0786eb949 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -535,7 +535,7 @@ function enforceHtmlBase(string $html, string $href): string { if ($head instanceof DOMElement) { $head->insertBefore($base, $head->firstChild); } else { - $doc->insertBefore($base, $doc->documentElement->firstChild); + $doc->documentElement->insertBefore($base, $doc->documentElement->firstChild); } } return $doc->saveHTML() ?: $html; -- cgit v1.2.3