]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fix of issue #677: When downloading images, wallabag doesnt respect html "base" tag... 737/head
authorMaryana Rozhankivska <mariroz@mr.lviv.ua>
Wed, 25 Jun 2014 17:00:00 +0000 (20:00 +0300)
committerMaryana Rozhankivska <mariroz@mr.lviv.ua>
Wed, 25 Jun 2014 17:00:00 +0000 (20:00 +0300)
inc/3rdparty/makefulltextfeed.php
inc/3rdparty/makefulltextfeedHelpers.php

index 62c050ec2bc368fd63fd265da8bfa1b888453782..a081f88b29f6800dab4cd2249366e35d45cd33dd 100755 (executable)
@@ -671,7 +671,11 @@ foreach ($items as $key => $item) {
                        $html .= $item->get_description();\r
                } else {\r
                        $readability->clean($content_block, 'select');\r
-                       if ($options->rewrite_relative_urls) makeAbsolute($effective_url, $content_block);\r
+                       // get base URL\r
+                       $base_url = get_base_url($readability->dom);\r
+                       if (!$base_url) $base_url = $effective_url;\r
+                       // rewrite URLs\r
+                       if ($options->rewrite_relative_urls) makeAbsolute($base_url, $content_block);\r
                        // footnotes\r
                        if (($links == 'footnotes') && (strpos($effective_url, 'wikipedia.org') === false)) {\r
                                $readability->addFootnotes($content_block);\r
index 4e985372c27b7f0780d54535acf3401b6c24087b..ac872ab85910a5a0bed6a08bfb822b7b8aadf9b1 100755 (executable)
@@ -377,3 +377,13 @@ function debug($msg) {
                flush();
        }
 }
+
+function get_base_url($dom) {\r
+       $xpath = new DOMXPath($dom);\r
+       $base_url = @$xpath->evaluate('string(//head/base/@href)', $dom);\r
+       if ($base_url !== '') {\r
+               return $base_url;\r
+       } else {\r
+               return false;\r
+       }\r
+}