]> git.wh0rd.org Git - tt-rss.git/commitdiff
Make af_readability use resolved URL when rewriting relative URLs in the article.
authorJustAMacUser <noreply@example.org>
Wed, 13 Dec 2017 05:17:43 +0000 (00:17 -0500)
committerJustAMacUser <noreply@example.org>
Wed, 13 Dec 2017 05:17:43 +0000 (00:17 -0500)
plugins/af_readability/init.php

index 192ad90b6efef9d8e8cb61fe1c25c006d4573c71..fbc8fe0ab1586373138b77fc850dbd3ba7fa6c72 100755 (executable)
@@ -154,6 +154,8 @@ class Af_Readability extends Plugin {
 
                        if (strpos($content_type, "text/html") === FALSE)
                                return false;
+
+                       $effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
                }
 
                $tmp = fetch_file_contents($url);
@@ -164,6 +166,9 @@ class Af_Readability extends Plugin {
                        if (!$tmpdoc->loadHTML('<?xml encoding="utf-8" ?>\n' . $tmp))
                                return false;
 
+                       if (!isset($effective_url))
+                               $effective_url = $url;
+
                        if (strtolower($tmpdoc->encoding) != 'utf-8') {
                                $tmpxpath = new DOMXPath($tmpdoc);
 
@@ -184,13 +189,13 @@ class Af_Readability extends Plugin {
                                foreach ($entries as $entry) {
                                        if ($entry->hasAttribute("href")) {
                                                $entry->setAttribute("href",
-                                                               rewrite_relative_url($url, $entry->getAttribute("href")));
+                                                               rewrite_relative_url($effective_url, $entry->getAttribute("href")));
 
                                        }
 
                                        if ($entry->hasAttribute("src")) {
                                                $entry->setAttribute("src",
-                                                               rewrite_relative_url($url, $entry->getAttribute("src")));
+                                                               rewrite_relative_url($effective_url, $entry->getAttribute("src")));
 
                                        }