summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2009-10-07 19:28:56 +0000
committerUrban Müller2009-10-07 19:28:56 +0000
commitbaaf85ca23b34506e788fe22b81e5bd394e62fc1 (patch)
tree17eaf369a66d5cbafbaf6e30d42a630655b93ea6
parent1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169 (diff)
downloaditools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.tar.gz
itools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.tar.bz2
itools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.zip
never trust the encoding
-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);
}