aboutsummaryrefslogtreecommitdiff
path: root/lib/SimplePie/SimplePie.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-04-08 11:13:01 +0200
committerGravatar GitHub <noreply@github.com> 2024-04-08 11:13:01 +0200
commit6e1278182155c6b1e8cef274368bd35510a2a14e (patch)
tree8bd9b972bb3405806906f5f3921957da14fd0621 /lib/SimplePie/SimplePie.php
parent283341e75e6ef4fbb3c522635b8a7805d3ab3a20 (diff)
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
Diffstat (limited to 'lib/SimplePie/SimplePie.php')
-rw-r--r--lib/SimplePie/SimplePie.php18
1 files changed, 10 insertions, 8 deletions
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 `<xml:base>` if available, otherwise uses the first link in the
- * feed, or failing that, the URL of the feed itself.
+ * Uses `<xml:base>` 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() ?? '';
}
/**