From 6e1278182155c6b1e8cef274368bd35510a2a14e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 8 Apr 2024 11:13:01 +0200 Subject: Fix SimplePie absolutize URL for several cases (#6270) This is especially relevant for HTML+XPath mode, for which we rely on proper URL "absolutize" Upstream PR https://github.com/simplepie/simplepie/pull/861 --- lib/SimplePie/SimplePie.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/SimplePie/SimplePie.php') diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index c0b2e24f6..25dcc7fad 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -2270,8 +2270,9 @@ class SimplePie /** * Get the base URL value from the feed * - * Uses `` if available, otherwise uses the first link in the - * feed, or failing that, the URL of the feed itself. + * Uses `` if available, + * otherwise uses the first 'self' link or the first 'alternate' link of the feed, + * or failing that, the URL of the feed itself. * * @see get_link * @see subscribe_url @@ -2281,16 +2282,17 @@ class SimplePie */ public function get_base($element = array()) { - if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) - { + if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) { return $element['xml_base']; } - elseif ($this->get_link() !== null) - { - return $this->get_link(); + if (($link = $this->get_link(0, 'self')) !== null) { + return $link; + } + if (($link = $this->get_link(0, 'alternate')) !== null) { + return $link; } - return $this->subscribe_url(); + return $this->subscribe_url() ?? ''; } /** -- cgit v1.2.3