]> git.wh0rd.org Git - tt-rss.git/commitdiff
Feedparser/encoding change: More general regular expression, set encoding to UTF...
authorwltb <github.11.el_robb_duderino@spamgourmet.com>
Sun, 14 Jul 2013 22:25:45 +0000 (00:25 +0200)
committerwltb <github.11.el_robb_duderino@spamgourmet.com>
Sun, 14 Jul 2013 22:25:45 +0000 (00:25 +0200)
classes/feedparser.php

index 53f6c52a95c51cf348a8f3efaf94b2a505247229..651ee010f5e4475d1d3c6242637c44e1dea5e014 100644 (file)
@@ -22,13 +22,13 @@ class FeedParser {
 
                // libxml compiled without iconv?
                if ($error && $error->code == 32) {
-                       if (preg_match('/^(<\\?xml .*?)encoding="(.+?)"(.*?\\?>)/', $data, $matches) === 1) {
+                       if (preg_match('/^(<\?xml[\t\n\r ].*?encoding=["\'])(.+?)(["\'].*?\?>)/s', $data, $matches) === 1) {
                                libxml_clear_errors();
 
                                $enc = $matches[2];
 
-                $data = iconv($enc, 'UTF-8//IGNORE', $data);
-                $data = preg_replace('/^<\\?xml .*?\\?>/', $matches[1] . $matches[3] , $data);
+                               $data = iconv($enc, 'UTF-8//IGNORE', $data);
+                               $data = preg_replace('/^<\?xml[\t\n\r ].*?\?>/s', $matches[1] . "UTF-8" . $matches[3] , $data);
 
                                $this->doc = new DOMDocument();
                                $this->doc->loadXML($data);