@@ 244-262 (lines=19) @@ | ||
241 | return $r; |
|
242 | } |
|
243 | ||
244 | if ($respEncoding != '') { |
|
245 | ||
246 | // Since parsing will fail if charset is not specified in the xml prologue, |
|
247 | // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that... |
|
248 | // The following code might be better for mb_string enabled installs, but |
|
249 | // makes the lib about 200% slower... |
|
250 | //if (!is_valid_charset($respEncoding, array('UTF-8'))) |
|
251 | if (!in_array($respEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($data)) { |
|
252 | if ($respEncoding == 'ISO-8859-1') { |
|
253 | $data = utf8_encode($data); |
|
254 | } else { |
|
255 | if (extension_loaded('mbstring')) { |
|
256 | $data = mb_convert_encoding($data, 'UTF-8', $respEncoding); |
|
257 | } else { |
|
258 | error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received response: ' . $respEncoding); |
|
259 | } |
|
260 | } |
|
261 | } |
|
262 | } |
|
263 | ||
264 | $parser = xml_parser_create(); |
|
265 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); |
@@ 474-491 (lines=18) @@ | ||
471 | { |
|
472 | // decompose incoming XML into request structure |
|
473 | ||
474 | if ($reqEncoding != '') { |
|
475 | // Since parsing will fail if charset is not specified in the xml prologue, |
|
476 | // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that... |
|
477 | // The following code might be better for mb_string enabled installs, but |
|
478 | // makes the lib about 200% slower... |
|
479 | //if (!is_valid_charset($reqEncoding, array('UTF-8'))) |
|
480 | if (!in_array($reqEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($data)) { |
|
481 | if ($reqEncoding == 'ISO-8859-1') { |
|
482 | $data = utf8_encode($data); |
|
483 | } else { |
|
484 | if (extension_loaded('mbstring')) { |
|
485 | $data = mb_convert_encoding($data, 'UTF-8', $reqEncoding); |
|
486 | } else { |
|
487 | error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $reqEncoding); |
|
488 | } |
|
489 | } |
|
490 | } |
|
491 | } |
|
492 | ||
493 | $parser = xml_parser_create(); |
|
494 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); |
@@ 239-257 (lines=19) @@ | ||
236 | { |
|
237 | // 'guestimate' encoding |
|
238 | $valEncoding = XMLParser::guessEncoding('', $xmlVal); |
|
239 | if ($valEncoding != '') { |
|
240 | ||
241 | // Since parsing will fail if charset is not specified in the xml prologue, |
|
242 | // the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that... |
|
243 | // The following code might be better for mb_string enabled installs, but |
|
244 | // makes the lib about 200% slower... |
|
245 | //if (!is_valid_charset($valEncoding, array('UTF-8')) |
|
246 | if (!in_array($valEncoding, array('UTF-8', 'US-ASCII')) && !XMLParser::hasEncoding($xmlVal)) { |
|
247 | if ($valEncoding == 'ISO-8859-1') { |
|
248 | $xmlVal = utf8_encode($xmlVal); |
|
249 | } else { |
|
250 | if (extension_loaded('mbstring')) { |
|
251 | $xmlVal = mb_convert_encoding($xmlVal, 'UTF-8', $valEncoding); |
|
252 | } else { |
|
253 | error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of xml text: ' . $valEncoding); |
|
254 | } |
|
255 | } |
|
256 | } |
|
257 | } |
|
258 | ||
259 | $parser = xml_parser_create(); |
|
260 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); |