Skip to content
Snippets Groups Projects
Commit d1f3fa97 authored by Andrew Dolgov's avatar Andrew Dolgov
Browse files

try to force-convert feed data to utf8

parent 175dd079
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,22 @@ class FeedParser { ...@@ -17,7 +17,22 @@ class FeedParser {
libxml_clear_errors(); libxml_clear_errors();
$this->doc = new DOMDocument(); $this->doc = new DOMDocument();
$this->doc->loadXML($data); $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(); libxml_clear_errors();
$this->items = array(); $this->items = array();
......
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
_debug("fetch done.", $debug_enabled); _debug("fetch done.", $debug_enabled);
if ($feed_data) { /* if ($feed_data) {
$error = verify_feed_xml($feed_data); $error = verify_feed_xml($feed_data);
if ($error) { if ($error) {
...@@ -307,7 +307,7 @@ ...@@ -307,7 +307,7 @@
if ($error) $feed_data = ''; if ($error) $feed_data = '';
} }
} }
} } */
} }
if (!$feed_data) { if (!$feed_data) {
...@@ -1349,14 +1349,14 @@ ...@@ -1349,14 +1349,14 @@
mb_strtolower(strip_tags($title), 'utf-8')); mb_strtolower(strip_tags($title), 'utf-8'));
} }
function verify_feed_xml($feed_data) { /* function verify_feed_xml($feed_data) {
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->loadXML($feed_data); $doc->loadXML($feed_data);
$error = libxml_get_last_error(); $error = libxml_get_last_error();
libxml_clear_errors(); libxml_clear_errors();
return $error; return $error;
} } */
function housekeeping_common($debug) { function housekeeping_common($debug) {
expire_cached_files($debug); expire_cached_files($debug);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment