From 4262e0019a519b2db4d6507ff0f2984ac1c6249a Mon Sep 17 00:00:00 2001 From: zaikos Date: Fri, 26 Dec 2014 14:43:38 -0500 Subject: [PATCH 1/3] Temporarily disable entity loader when importing XML file. --- plugins/import_export/init.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php index d185210ee..e61b62b67 100644 --- a/plugins/import_export/init.php +++ b/plugins/import_export/init.php @@ -189,6 +189,8 @@ class Import_Export extends Plugin implements IHandler { $num_processed = 0; $num_feeds_created = 0; + libxml_disable_entity_loader(false); + $doc = @DOMDocument::load($filename); if (!$doc) { @@ -206,6 +208,8 @@ class Import_Export extends Plugin implements IHandler { $doc = DOMDocument::loadXML($data); } + libxml_disable_entity_loader(true); + if ($doc) { $xpath = new DOMXpath($doc); From be60340c296637fc269bf53adff4910911219db0 Mon Sep 17 00:00:00 2001 From: zaikos Date: Wed, 14 Jan 2015 13:28:58 -0500 Subject: [PATCH 2/3] Made FeedItem_RSS::get_title() more aggresive in finding an article title. --- classes/feeditem/rss.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index c9a7467cd..0e2b77ac7 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -51,10 +51,14 @@ class FeedItem_RSS extends FeedItem_Common { } function get_title() { - $title = $this->elem->getElementsByTagName("title")->item(0); + $titles = $this->elem->getElementsByTagName("title"); - if ($title) { - return trim($title->nodeValue); + foreach ($titles as $title) { + $nv = trim($title->nodeValue); + + if (!empty($nv)) { + return $nv; + } } } From 2b4853f515c2deeb9026387afd40d9158a5ccd0a Mon Sep 17 00:00:00 2001 From: zaikos Date: Wed, 14 Jan 2015 16:13:39 -0500 Subject: [PATCH 3/3] Reverts most of be60340. Implements a simplier solution using XPath to get the proper title tag from a feed item. --- classes/feeditem/rss.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 0e2b77ac7..7b4c4fb0c 100644 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -51,14 +51,10 @@ class FeedItem_RSS extends FeedItem_Common { } function get_title() { - $titles = $this->elem->getElementsByTagName("title"); + $title = $this->xpath->query("title", $this->elem)->item(0); - foreach ($titles as $title) { - $nv = trim($title->nodeValue); - - if (!empty($nv)) { - return $nv; - } + if ($title) { + return trim($title->nodeValue); } }