diff options
author | Urban Müller | 2009-10-07 16:21:12 +0000 |
---|---|---|
committer | Urban Müller | 2009-10-07 16:21:12 +0000 |
commit | 1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169 (patch) | |
tree | e091545c983b5cdef4f383423b42f0e399a313e2 /it_xml.class | |
parent | f9789a730edac3133cd2ec7117c8a66465027fdd (diff) | |
download | itools-1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169.tar.gz itools-1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169.tar.bz2 itools-1b2eb1bd5843ac60bc31dfddb0e9d02d23cd6169.zip |
handle blanks before <?xml
Diffstat (limited to 'it_xml.class')
-rw-r--r-- | it_xml.class | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/it_xml.class b/it_xml.class index bacae95..8fe7f38 100644 --- a/it_xml.class +++ b/it_xml.class @@ -70,7 +70,7 @@ function from_xml($xmldata, $p) if (is_resource($xmldata)) { - if (!preg_match('/^<\?xml/', ($head = fread($xmldata, 1024 * 1024)))) # Prepend XML header for charset detection in PHP5 + if (!preg_match('/^<\?xml/', ($head = ltrim(fread($xmldata, 1024 * 1024))))) # Prepend XML header for charset detection in PHP5 $head = '<?xml version="1.0" encoding="' . $this->_p['encoding'] . '"?>' . $head; $result = xml_parse($parser, $head, false); @@ -85,6 +85,7 @@ function from_xml($xmldata, $p) { # Add header for charset detection (PHP5) if no header/BOM # See http://www.w3.org/TR/2006/REC-xml-20060816/#sec-guessing + $xmldata = trim($xmldata); if (!preg_match('/^(<\?xml|\xEF\xBB\xBF|\xFE\xFF|\xFF\xFE|\x00\x00\xFE\xFF|\x00\x00\xFF\xFE)/', $xmldata)) $xmldata = '<?xml version="1.0" encoding="' . $this->_p['encoding'] . '"?>' . $xmldata; |