Sfoglia il codice sorgente

SimplePie fix base (#4565)

* SimplePie fix base
#fix https://github.com/FreshRSS/FreshRSS/issues/4562
See `<xml:base>` example in https://datatracker.ietf.org/doc/html/rfc4287#section-1.1
First uses item `<xml:base>` if it exists, or the item own link, or the feed's base URL rules (feed URL, or Web site URL)

* Minor formatting
Alexandre Alapetite 3 anni fa
parent
commit
442019a054
1 ha cambiato i file con 9 aggiunte e 3 eliminazioni
  1. 9 3
      lib/SimplePie/SimplePie/Item.php

+ 9 - 3
lib/SimplePie/SimplePie/Item.php

@@ -152,15 +152,21 @@ class SimplePie_Item
 	}
 
 	/**
-	 * Get the base URL value from the parent feed
-	 *
-	 * Uses `<xml:base>`
+	 * Get the base URL value.
+	 * Uses `<xml:base>`, or item link, or feed base URL.
 	 *
 	 * @param array $element
 	 * @return string
 	 */
 	public function get_base($element = array())
 	{
+		if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
+			return $element['xml_base'];
+		}
+		$link = $this->get_permalink();
+		if ($link != null) {
+			return $link;
+		}
 		return $this->feed->get_base($element);
 	}