Code Duplication    Length = 11-19 lines in 3 locations

lib/xmlrpcs.inc 1 location

@@ 940-958 (lines=19) @@
937
938
			// decompose incoming XML into request structure
939
940
			if ($req_encoding != '')
941
			{
942
				// Since parsing will fail if charset is not specified in the xml prologue,
943
				// the encoding is not UTF8 and there are non-ascii chars in the text, we try to work round that...
944
				// The following code might be better for mb_string enabled installs, but
945
				// makes the lib about 200% slower...
946
				//if (!is_valid_charset($req_encoding, array('UTF-8')))
947
				if (!in_array($req_encoding, array('UTF-8', 'US-ASCII')) && !has_encoding($data)) {
948
					if ($req_encoding == 'ISO-8859-1') {
949
						$data = utf8_encode($data);
950
					} else {
951
						if (extension_loaded('mbstring')) {
952
							$data = mb_convert_encoding($data, 'UTF-8', $req_encoding);
953
						} else {
954
							error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $req_encoding);
955
						}
956
					}
957
				}
958
			}
959
960
			$parser = xml_parser_create();
961
			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);

lib/xmlrpc.inc 2 locations

@@ 2645-2655 (lines=11) @@
2642
			// The following code might be better for mb_string enabled installs, but
2643
			// makes the lib about 200% slower...
2644
			//if (!is_valid_charset($resp_encoding, array('UTF-8')))
2645
			if (!in_array($resp_encoding, array('UTF-8', 'US-ASCII')) && !has_encoding($data)) {
2646
				if ($resp_encoding == 'ISO-8859-1') {
2647
					$data = utf8_encode($data);
2648
				} else {
2649
					if (extension_loaded('mbstring')) {
2650
						$data = mb_convert_encoding($data, 'UTF-8', $resp_encoding);
2651
					} else {
2652
						error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $resp_encoding);
2653
					}
2654
				}
2655
			}
2656
2657
			$parser = xml_parser_create();
2658
			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
@@ 3631-3641 (lines=11) @@
3628
		// The following code might be better for mb_string enabled installs, but
3629
		// makes the lib about 200% slower...
3630
		//if (!is_valid_charset($val_encoding, array('UTF-8')))
3631
		if (!in_array($val_encoding, array('UTF-8', 'US-ASCII')) && !has_encoding($xml_val)) {
3632
			if ($val_encoding == 'ISO-8859-1') {
3633
				$xml_val = utf8_encode($xml_val);
3634
			} else {
3635
				if (extension_loaded('mbstring')) {
3636
					$xml_val = mb_convert_encoding($xml_val, 'UTF-8', $val_encoding);
3637
				} else {
3638
					error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $val_encoding);
3639
				}
3640
			}
3641
		}
3642
3643
		$parser = xml_parser_create();
3644
		xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);