]> git.wh0rd.org Git - tt-rss.git/commitdiff
try to force-convert feed data to utf8
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 17 May 2013 16:09:43 +0000 (20:09 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 17 May 2013 16:09:43 +0000 (20:09 +0400)
classes/feedparser.php
include/rssfuncs.php

index bd67ca39d9e7730e3390185e08ee19dffe490bc4..6b84e59c787362759694b64268947934fea359d6 100644 (file)
@@ -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();
index 612c914c034b2f6cc75498c3f334b7cb9fccb059..e7c9f57dde38d1842d5989007b41be8c4d5b5ae4 100644 (file)
 
                                _debug("fetch done.", $debug_enabled);
 
-                               if ($feed_data) {
+                               /* if ($feed_data) {
                                        $error = verify_feed_xml($feed_data);
 
                                        if ($error) {
                                                        if ($error) $feed_data = '';
                                                }
                                        }
-                               }
+                               } */
                        }
 
                        if (!$feed_data) {
                        mb_strtolower(strip_tags($title), 'utf-8'));
        }
 
-       function verify_feed_xml($feed_data) {
+       /* function verify_feed_xml($feed_data) {
                libxml_use_internal_errors(true);
                $doc = new DOMDocument();
                $doc->loadXML($feed_data);
                $error = libxml_get_last_error();
                libxml_clear_errors();
                return $error;
-       }
+       } */
 
        function housekeeping_common($debug) {
                expire_cached_files($debug);