From cf1da74fa947682719b9038f734603e201793cf5 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sun, 19 Apr 2015 00:26:52 +0100 Subject: [PATCH] Fix: make debugger work correctly when any field value is LATIN-1 --- debugger/action.php | 107 ++++++++++++++++++++-------------------- debugger/common.php | 3 ++ debugger/controller.php | 28 +++++------ 3 files changed, 71 insertions(+), 67 deletions(-) diff --git a/debugger/action.php b/debugger/action.php index f79aba0..717dbee 100644 --- a/debugger/action.php +++ b/debugger/action.php @@ -208,7 +208,7 @@ td form {margin: 0;} // Before calling execute, echo out brief description of action taken + date and time ??? // this gives good user feedback for long-running methods... - echo '

'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server)." ...

\n"; + echo '

'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset)." ...

\n"; flush(); $response = null; @@ -237,16 +237,16 @@ td form {margin: 0;} if ($response->faultCode()) { // call failed! echo out error msg! - //echo '

'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'

'; + //echo '

'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'

'; echo "

$protoname call FAILED!

\n"; - echo "

Fault code: [" . htmlspecialchars($response->faultCode()) . - "] Reason: '" . htmlspecialchars($response->faultString()) . "'

\n"; + echo "

Fault code: [" . htmlspecialchars($response->faultCode(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']) . + "] Reason: '" . htmlspecialchars($response->faultString(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']) . "'

\n"; echo (strftime("%d/%b/%Y:%H:%M:%S\n")); } else { // call succeeded: parse results - //echo '

'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'

'; + //echo '

'.htmlspecialchars($actionname, ENT_COMPAT, $inputcharset).' on server '.htmlspecialchars($server, ENT_COMPAT, $inputcharset).'

'; printf ("

%s call(s) OK (%.2f secs.)

\n", $protoname, $time); echo (strftime("%d/%b/%Y:%H:%M:%S\n")); @@ -264,26 +264,26 @@ td form {margin: 0;} { $rec = $v->arraymem($i); if ($i%2) $class=' class="oddrow"'; else $class = ' class="evenrow"'; - echo ("".htmlspecialchars($rec->scalarval())."
". - "". - "". - "". - "". + echo ("".htmlspecialchars($rec->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding'])."". + "". + "". + "". + "". "". - "". - "". + "". + "". "". "". "". - "". - "". - "". - "". + "". + "". + "". + "". "". "". - "". + "". "". - "". + "". "scalarval()."\" />". "". "". @@ -314,8 +314,8 @@ td form {margin: 0;} $r2 = $resp[1]->value(); echo "\n"; - echo "\n\n\n\n"; - $desc = htmlspecialchars($r1->scalarval()); + echo "\n\n\n\n"; + $desc = htmlspecialchars($r1->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']); if ($desc == "") $desc = "-"; echo "\n"; @@ -333,7 +333,7 @@ td form {margin: 0;} if ($x->kindOf()=="array") { $ret = $x->arraymem(0); - echo "OUT: " . htmlspecialchars($ret->scalarval()) . "
IN: ("; + echo "OUT: " . htmlspecialchars($ret->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']) . "
IN: ("; if ($x->arraysize() > 1) { for($k = 1; $k < $x->arraysize(); $k++) @@ -342,7 +342,7 @@ td form {margin: 0;} echo $y->scalarval(); if ($wstype != 1) { - $payload = $payload . '<'.htmlspecialchars($y->scalarval()).'>scalarval()).">\n"; + $payload = $payload . '<'.htmlspecialchars($y->scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']).'>scalarval(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']).">\n"; } $alt_payload .= $y->scalarval(); if ($k < $x->arraysize()-1) @@ -362,28 +362,28 @@ td form {margin: 0;} //bottone per testare questo metodo //$payload="\n$method\n\n$payload\n"; echo "". - "". - "". - "". - "". + "". + "". + "". + "". "". - "". - "". + "". + "". "". "". "". - "". - "". - "". - "". + "". + "". + "". + "". "". "". - "". + "". "". - "". - "". - "". - "". + "". + "". + "". + "". "". ""; if ($wstype != 1) @@ -391,29 +391,29 @@ td form {margin: 0;} echo "\n"; echo "
". - "". - "". - "". - "". + "". + "". + "". + "". "". - "". - "". + "". + "". "". "". "". - "". - "". - "". - "". + "". + "". + "". + "". "". "". - "". + "". "". - "". - "". + "". + "". "". - "". - "". + "". + "". "". "". "". @@ -470,7 +470,7 @@ td form {margin: 0;} break; case 'execute': - echo '

Response:

'.htmlspecialchars($response->serialize()).'
'; + echo '

Response:

'.htmlspecialchars($response->serialize(), ENT_COMPAT, $GLOBALS['xmlrpc_internalencoding']).'
'; break; default: // give a warning @@ -507,6 +507,7 @@ Path: /server.php

Changelog

    +
  • 2015-04-19: fixed errors with LATIN-1 payloads and method names
  • 2007-02-20: add visual editor for method payload; allow strings, bools as jsonrpc msg id
  • 2006-06-26: support building php code stub for calling remote methods
  • 2006-05-25: better support for long running queries; check for no-curl installs
  • diff --git a/debugger/common.php b/debugger/common.php index adaf366..89a995b 100644 --- a/debugger/common.php +++ b/debugger/common.php @@ -22,10 +22,13 @@ $_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; + $inputcharset = mb_detect_encoding(implode('', $_GET), $preferredEncodings); } // recover input parameters diff --git a/debugger/controller.php b/debugger/controller.php index afb34ad..6d2e62c 100644 --- a/debugger/controller.php +++ b/debugger/controller.php @@ -223,9 +223,9 @@ td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt;
Method".htmlspecialchars($method)."  
Method".htmlspecialchars($method, ENT_COMPAT, $inputcharset)."  
Description$desc
- - - + + +

Target server

Address:Port:Path:Address:Port:Path:
@@ -238,14 +238,14 @@ td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt; Generate stub for method call onclick="switchaction();" /> - + - - - + + + @@ -269,8 +269,8 @@ td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt; - - + + - + - - - + + + @@ -311,7 +311,7 @@ td {vertical-align: top; font-family: Verdana, Arial, Helvetica; font-size: 8pt; - +

Method

Name:Payload:
Msg id: Name:Payload:
Msg id:
AUTH:Username:Pwd:Username:Pwd: Type Verify Cert: />CA Cert file:CA Cert file:
PROXY:Server:Proxy user:Proxy pwd:Server:Proxy user:Proxy pwd:
COMPRESSION:
COOKIES: Format: 'cookie1=value1, cookie2=value2'
-- 2.43.0