]> git.wh0rd.org - tt-rss.git/commitdiff
Merge branch 'master' of git.tt-rss.org:git/tt-rss into pdo-experimental
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 13 Dec 2017 05:21:50 +0000 (08:21 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 13 Dec 2017 05:21:50 +0000 (08:21 +0300)
1  2 
plugins/af_readability/init.php

index 10de118f9bbd31522410007345c26ff07285b42c,fbc8fe0ab1586373138b77fc850dbd3ba7fa6c72..04673000a19240f56512f1e15050df6c62bd2d81
@@@ -1,7 -1,6 +1,7 @@@
  <?php
  class Af_Readability extends Plugin {
  
 +      /* @var PluginHost $host */
        private $host;
  
        function about() {
@@@ -15,7 -14,7 +15,7 @@@
        }
  
        function save() {
 -              $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]) == "true";
 +              $enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]);
  
                $this->host->set($this, "enable_share_anything", $enable_share_anything);
  
                $enabled_feeds = $this->host->get($this, "enabled_feeds");
                if (!is_array($enabled_feeds)) $enabled_feeds = array();
  
 -              $enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]) == 'true';
 +              $enable = checkbox_to_sql_bool($_POST["af_readability_enabled"]);
                $key = array_search($feed_id, $enabled_feeds);
  
                if ($enable) {
  
                        if (strpos($content_type, "text/html") === FALSE)
                                return false;
+                       $effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
                }
  
                $tmp = fetch_file_contents($url);
                        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);
  
                                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")));
  
                                        }
  
  
                foreach ($enabled_feeds as $feed) {
  
 -                      $result = db_query("SELECT id FROM ttrss_feeds WHERE id = '$feed' AND owner_uid = " . $_SESSION["uid"]);
 +                      $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
 +                      $sth->execute([$feed, $_SESSION['uid']]);
  
 -                      if (db_num_rows($result) != 0) {
 +                      if ($row = $sth->fetch()) {
                                array_push($tmp, $feed);
                        }
                }