summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_xml.class3
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;