Fix: debugger has problems with latin-1 characters in payload
authorgggeek <giunta.gaetano@gmail.com>
Fri, 10 Apr 2015 11:05:42 +0000 (12:05 +0100)
committergggeek <giunta.gaetano@gmail.com>
Fri, 10 Apr 2015 11:05:42 +0000 (12:05 +0100)
NEWS
debugger/action.php
debugger/common.php

diff --git a/NEWS b/NEWS
index 61e0fc0..ee0d49a 100644 (file)
--- 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
 
index 69f66e0..0345798 100644 (file)
@@ -226,7 +226,7 @@ if ($action) {
                     }
                 }
             } else {
-                $msg[0]->payload = $msg[0]->xml_header() .
+                $msg[0]->payload = $msg[0]->xml_header($inputcharset) .
                     '<methodName>' . $method . "</methodName>\n<params>" .
                     $payload .
                     "</params>\n" . $msg[0]->xml_footer();
@@ -248,8 +248,7 @@ if ($action) {
         echo '<div class="dbginfo"><h2>Debug info:</h2>';
     }  /// @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 "</div>\n";
     }
index e8ad64c..ecd09cf 100644 (file)
@@ -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