$GLOBALS['_xh']['rt']='';\r
\r
// decompose incoming XML into request structure\r
+\r
if ($req_encoding != '')\r
{\r
- if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))\r
- // the following code might be better for mb_string enabled installs, but\r
- // makes the lib about 200% slower...\r
- //if (!is_valid_charset($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII')))\r
- {\r
- error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$req_encoding);\r
- $req_encoding = $GLOBALS['xmlrpc_defencoding'];\r
- }\r
- /// @BUG this will fail on PHP 5 if charset is not specified in the xml prologue,\r
- // the encoding is not UTF8 and there are non-ascii chars in the text...\r
- /// @todo use an empty string for php 5 ???\r
- $parser = xml_parser_create($req_encoding);\r
- }\r
- else\r
- {\r
- $parser = xml_parser_create();\r
+ // Since parsing will fail if charset is not specified in the xml prologue,\r
+ // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that...\r
+ // The following code might be better for mb_string enabled installs, but\r
+ // makes the lib about 200% slower...\r
+ //if (!is_valid_charset($req_encoding, array('UTF-8')))\r
+ if (!in_array($req_encoding, array('UTF-8', 'US-ASCII')) && !has_encoding($data)) {\r
+ if ($req_encoding == 'ISO-8859-1') {\r
+ $data = utf8_encode($data);\r
+ } else {\r
+ if (extension_loaded('mbstring')) {\r
+ $data = mb_convert_encoding($data, 'UTF-8', $req_encoding);\r
+ } else {\r
+ error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $req_encoding);\r
+ }\r
+ }\r
+ }\r
}\r
\r
+ $parser = xml_parser_create();\r
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);\r
// G. Giunta 2005/02/13: PHP internally uses ISO-8859-1, so we have to tell\r
// the xml parser to give us back data in the expected charset\r