summaryrefslogtreecommitdiff
path: root/plugins/af_readability
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-07-06 23:29:00 +0300
committerAndrew Dolgov <[email protected]>2015-07-06 23:29:00 +0300
commitfd61fd6e7928c6fd88c6027868f096b35216d9fe (patch)
treef73528700f7b5176af27dff19cdf8dceb75a587f /plugins/af_readability
parente2a3689a1889c5df124b8d44131f3337d59d8ebd (diff)
rewrite relative urls in readability output
Diffstat (limited to 'plugins/af_readability')
-rw-r--r--plugins/af_readability/init.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php
index 161458c79..8e47d7640 100644
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -104,6 +104,26 @@ class Af_Readability extends Plugin {
$r = new Readability($tmp, $article["link"]);
if ($r->init()) {
+
+ $tmpxpath = new DOMXPath($r->dom);
+
+ $entries = $tmpxpath->query('(//a[@href]|//img[@src])');
+
+ foreach ($entries as $entry) {
+ if ($entry->hasAttribute("href")) {
+ $entry->setAttribute("href",
+ rewrite_relative_url($entry->getAttribute("href"), $article["link"]));
+
+ }
+
+ if ($entry->hasAttribute("src")) {
+ $entry->setAttribute("src",
+ rewrite_relative_url($entry->getAttribute("src"), $article["link"]));
+
+ }
+
+ }
+
$article["content"] = $r->articleContent->innerHTML;
}
}