diff options
author | Urban Müller | 2009-10-07 19:28:56 +0000 |
---|---|---|
committer | Urban Müller | 2009-10-07 19:28:56 +0000 |
commit | baaf85ca23b34506e788fe22b81e5bd394e62fc1 (patch) | |
tree | 17eaf369a66d5cbafbaf6e30d42a630655b93ea6 /it_xml.class | |
parent | 1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169 (diff) | |
download | itools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.tar.gz itools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.tar.bz2 itools-baaf85ca23b34506e788fe22b81e5bd394e62fc1.zip |
never trust the encoding
Diffstat (limited to 'it_xml.class')
-rw-r--r-- | it_xml.class | 5 |
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); } |