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

parser: only try to convert encoding if mbstring actually supports it

parent 733b257d
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,11 @@ class FeedParser {
function normalize_encoding($data) {
if (preg_match('/^(<\?xml[\t\n\r ].*?encoding[\t\n\r ]*=[\t\n\r ]*["\'])(.+?)(["\'].*?\?>)/s', $data, $matches) === 1) {
$data = mb_convert_encoding($data, 'UTF-8', $matches[2]);
$encoding = strtolower($matches[2]);
if (in_array($encoding, mb_list_encodings()))
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
$data = preg_replace('/^<\?xml[\t\n\r ].*?\?>/s', $matches[1] . "UTF-8" . $matches[3] , $data);
}
......
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