fix: the client can now successfully call methods using ISO-8859-1 or UTF-8 character...
[plcapi.git] / debugger / common.php
index 69b89ba..ea389a6 100644 (file)
@@ -2,7 +2,9 @@
 /**
  * @author Gaetano Giunta
  * @copyright (C) 2005-2015 G. Giunta
- * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
+ * @license code licensed under the BSD License: see file license.txt
+ *
+ * Parses GET/POST variables
  *
  * @todo switch params for http compression from 0,1,2 to values to be used directly
  * @todo do some more sanitization of received parameters
@@ -22,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;
+    /// @bug this is not a perfect detection method - it will fail if eg. a latin1 character is in the method name
+    $inputcharset = mb_detect_encoding(urldecode(isset($_GET['methodpayload'])) ? $_GET['methodpayload'] : '', $preferredEncodings);
 }
 
 // recover input parameters