summaryrefslogtreecommitdiff
path: root/classes/feedparser.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-05-17 20:09:43 +0400
committerAndrew Dolgov <[email protected]>2013-05-17 20:09:43 +0400
commitd1f3fa9791a48de4991e8eae9e9939afd0316be3 (patch)
tree88b0f6caf070c968c2a16ab447e697ca2e3ef655 /classes/feedparser.php
parent175dd0794e132180406d008fbb510c4bb53da779 (diff)
try to force-convert feed data to utf8
Diffstat (limited to 'classes/feedparser.php')
-rw-r--r--classes/feedparser.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/classes/feedparser.php b/classes/feedparser.php
index bd67ca39d..6b84e59c7 100644
--- a/classes/feedparser.php
+++ b/classes/feedparser.php
@@ -17,7 +17,22 @@ class FeedParser {
libxml_clear_errors();
$this->doc = new DOMDocument();
$this->doc->loadXML($data);
- $this->error = $this->format_error(libxml_get_last_error());
+
+ $error = libxml_get_last_error();
+
+ if ($error && $error->code == 9) {
+ libxml_clear_errors();
+
+ // we might want to try guessing input encoding here too
+ $data = iconv("UTF-8", "UTF-8//IGNORE", $data);
+
+ $this->doc = new DOMDocument();
+ $this->doc->loadXML($data);
+
+ $error = libxml_get_last_error();
+ }
+
+ $this->error = $this->format_error($error);
libxml_clear_errors();
$this->items = array();