From da824472c0045c183f40792b8c760c11d024005d Mon Sep 17 00:00:00 2001 From: gggeek Date: Fri, 10 Apr 2015 12:05:42 +0100 Subject: [PATCH] Fix: debugger has problems with latin-1 characters in payload --- NEWS | 2 ++ debugger/action.php | 8 +++----- debugger/common.php | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 61e0fc0..ee0d49a 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,8 @@ PLEASE READ CAREFULLY THE NOTES BELOW to insure a smooth upgrade. * improved: the testsuite has basic checks for the debugger and demo files +* fixed: the debugger would fail sending a request with ISO-8859-1 payload + XML-RPC for PHP version 3.0.0 - 2014/6/15 diff --git a/debugger/action.php b/debugger/action.php index 69f66e0..0345798 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -226,7 +226,7 @@ if ($action) { } } } else { - $msg[0]->payload = $msg[0]->xml_header() . + $msg[0]->payload = $msg[0]->xml_header($inputcharset) . '' . $method . "\n" . $payload . "\n" . $msg[0]->xml_footer(); @@ -248,8 +248,7 @@ if ($action) { echo '

Debug info:

'; } /// @todo use ob_start instead $resp = array(); - $mtime = explode(' ', microtime()); - $time = (float)$mtime[0] + (float)$mtime[1]; + $time = microtime(true); foreach ($msg as $message) { // catch errors: for older xmlrpc libs, send does not return by ref @$response = $client->send($message, $timeout, $httpprotocol); @@ -258,8 +257,7 @@ if ($action) { break; } } - $mtime = explode(' ', microtime()); - $time = (float)$mtime[0] + (float)$mtime[1] - $time; + $time = microtime(true) - $time; if ($debug) { echo "
\n"; } diff --git a/debugger/common.php b/debugger/common.php index e8ad64c..ecd09cf 100644 --- a/debugger/common.php +++ b/debugger/common.php @@ -24,8 +24,12 @@ if (get_magic_quotes_gpc()) { $_GET = array_map('stripslashes_deep', $_GET); } +$preferredEncodings = 'UTF-8, ASCII, ISO-8859-1, UTF-7, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP'; +$inputcharset = mb_detect_encoding(urldecode($_SERVER['REQUEST_URI']), $preferredEncodings); if (isset($_GET['usepost']) && $_GET['usepost'] === 'true') { $_GET = $_POST; + /// @todo detect encoding, eg from from http headers? + // mb_detect_encoding(urldecode($_SERVER['...']), $preferredEncodings); } // recover input parameters -- 2.43.0