summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_xml.class5
1 files changed, 3 insertions, 2 deletions
diff --git a/it_xml.class b/it_xml.class
index 8fe7f38..69754ff 100644
--- a/it_xml.class
+++ b/it_xml.class
@@ -93,8 +93,9 @@ function from_xml($xmldata, $p)
$xmldata = html_entity_decode(preg_replace('/&(amp|lt|gt|#38|#60|#62|#x26|#x3C|#x3E);/i', '&$1;', $xmldata), ENT_QUOTES, $this->_p['encoding']);
# If should be utf-8 and can't be decoded as such, fix it, even if mixed between both
- if (!preg_match('/^<\?xml[^>]* encoding=/', $xmldata) && preg_match('/[^\x80-\xff][\x80-\xff][^\x80-\xff]/', $xmldata))
- $xmldata = preg_replace('/[\x80-\xff]{1,4}/e', "it_xml::_utf8_fix('\\0')", $xmldata);
+ if (!preg_match('/^<\?xml[^>]* encoding=/i', $xmldata) || preg_match('/^<\?xml[^>]* encoding=.UTF-8/i', $xmldata))
+ if (preg_match('/[^\x80-\xff][\x80-\xff][^\x80-\xff]/', $xmldata))
+ $xmldata = preg_replace('/[\x80-\xff]{1,4}/e', "it_xml::_utf8_fix('\\0')", $xmldata);
$result = xml_parse($parser, $xmldata);
}