summaryrefslogtreecommitdiff
path: root/plugins/af_redditimgur
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2016-01-23 11:51:17 +0300
committerAndrew Dolgov <[email protected]>2016-01-23 11:51:17 +0300
commit8f2268dd5e45da32a9d1cff1e8781fd840c1043e (patch)
treeaf2eb17b333b99cd326a40fabe52aa984799e8d2 /plugins/af_redditimgur
parent0bc503ff9a74a0ca34bb21d78f4fd2aea02d3bd8 (diff)
af_redditimgur: implement a hack to deal with reddit rss feed being currently broken
Diffstat (limited to 'plugins/af_redditimgur')
-rwxr-xr-xplugins/af_redditimgur/init.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index 3ff960729..1ab696ce3 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -244,6 +244,32 @@ class Af_RedditImgur extends Plugin {
$found = $this->inline_stuff($article, $doc, $xpath);
+ // reddit decided to break its rss because of thunderbird so let's implement a temporary hack
+ // see also: https://www.reddit.com/r/changelog/comments/428vdq/upcoming_reddit_change_switching_from_rss_20_to/
+
+ $textnode = $xpath->query("//*[text()[contains(.,'!-- SC_OFF')]]/text()")->item(0);
+
+ if ($textnode) {
+
+ $badhtml = htmlspecialchars_decode($textnode->textContent);
+ $textnode->textContent = "";
+
+ if ($badhtml) {
+ $body = $doc->getElementsByTagName("body")->item(0);
+
+ $tmp = new DOMDocument;
+
+ if (@$tmp->loadHTML($badhtml)) {
+ $newnode = $doc->importNode($tmp->documentElement, TRUE);
+
+ if ($newnode) {
+ $body->insertBefore($newnode, $body->firstChild);
+ $found = 1;
+ }
+ }
+ }
+ }
+
if (!defined('NO_CURL') && function_exists("curl_init") && !$found && $this->host->get($this, "enable_readability") &&
mb_strlen(strip_tags($article["content"])) <= 150) {