Backward compatibility is maintained via lib/xmlrpc.inc, lib/xmlrpcs.inc and lib/xmlrpc_wrappers.inc.
For more details, head on to doc/api_changes_v4.md
+* changed: the default encoding delivered from the library to your code is now utf8.
+ It can be changed at anytime setting a value to PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding
+
* improved: all php code is now formatted according to the PSR-2 standard
* improved: no need to call anymore $client->setSSLVerifyHost(2) to silence a curl warning when using https
* fixed: the client can now successfully call methods using ISO-8859-1 or UTF-8 characters in their name
-* improved: echo all debug messages even when there are characters in them which php deems in a wrong encoding
+* improved: echo all debug messages even when there are characters in them which php deems to be in a wrong encoding
(this is visible e.g. in the debugger)
* changed: debug info handling
"tests.raiseException" => array(
"function" => array($object, "exceptionGenerator"),
),
- /*
// Greek word 'kosme'. NB: NOT a valid ISO8859 string!
- // We can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
+ // NB: we can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
"tests.utf8methodname." . 'κόσμε' => array(
"function" => "stringEcho",
"signature" => $stringecho_sig,
"docstring" => $stringecho_doc,
- ),*/
- "tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
+ ),
+ /*"tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
"function" => "stringEcho",
"signature" => $stringecho_sig,
"docstring" => $stringecho_doc,
- ),
+ ),*/
"examples.getallheaders" => array(
"function" => 'getallheaders_xmlrpc',
"signature" => $getallheaders_sig,
include_once(__DIR__.'/../src/Response.php');
include_once(__DIR__.'/../src/Client.php');
include_once(__DIR__.'/../src/Encoder.php');
-include_once(__DIR__.'/../src/Helper/Date.php');
include_once(__DIR__.'/../src/Helper/Charset.php');
+include_once(__DIR__.'/../src/Helper/Date.php');
include_once(__DIR__.'/../src/Helper/Http.php');
+include_once(__DIR__.'/../src/Helper/Logger.php');
include_once(__DIR__.'/../src/Helper/XMLParser.php');
/* Expose the global variables which used to be defined */
+PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1'; // old default
PhpXmlRpc\PhpXmlRpc::exportGlobals();
/* some stuff deprecated enough that we do not want to put it in the new lib version */
return PhpXmlRpc\Helper\XMLParser::guessEncoding($httpHeader, $xmlChunk, $encodingPrefs);
}
+function has_encoding($xmlChunk)
+{
+ return PhpXmlRpc\Helper\XMLParser::hasEncoding($xmlChunk);
+}
+
function is_valid_charset($encoding, $validList)
{
return PhpXmlRpc\Helper\Charset::instance()->is_valid_charset($encoding, $validList);
// The encoding used internally by PHP.
// String values received as xml will be converted to this, and php strings will be converted to xml
- // as if having been coded with this
- public static $xmlrpc_internalencoding = "ISO-8859-1"; // TODO: maybe this would be better as UTF-8
+ // as if having been coded with this.
+ // Valid also when defining names of xmlrpc methods
+ public static $xmlrpc_internalencoding = "UTF-8";
public static $xmlrpcName = "XML-RPC for PHP";
public static $xmlrpcVersion = "4.0.0.beta";
$v = new xmlrpcval('-1');
$u = new xmlrpcval('-1', 'string');
$t = new xmlrpcval(-1, 'string');
- $this->assertEquals($u->scalarval(), $v->scalarval());
- $this->assertEquals($t->scalarval(), $v->scalarval());
+ $this->assertEquals($v->scalarval(), $u->scalarval());
+ $this->assertEquals($v->scalarval(), $t->scalarval());
}
/**
*/
public function testMinusOneInt()
{
- $v = new xmlrpcval(-1);
$u = new xmlrpcval();
+ $v = new xmlrpcval(-1);
$this->assertEquals($u->scalarval(), $v->scalarval());
}
$m = $this->newMsg('dummy');
$r = $m->parseResponse($r);
$v = $r->value();
- $this->assertEquals($v->structmemexists($str), true);
+ $this->assertEquals(true, $v->structmemexists($str));
}
public function testUnicodeInErrorString()
if (is_array($errorCode)) {
$this->assertContains($r->faultCode(), $errorCode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
} else {
- $this->assertEquals($r->faultCode(), $errorCode, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
+ $this->assertEquals($errorCode, $r->faultCode(), 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
}
if (!$r->faultCode()) {
if ($returnResponse) {
}
}
- public function testLatin1Method()
+ /*public function testLatin1Method()
{
$f = new xmlrpcmsg("tests.iso88591methodname." . chr(224) . chr(252) . chr(232), array(
new xmlrpcval('hello')
if ($v) {
$this->assertEquals('hello', $v->scalarval());
}
- }
+ }*/
- /*public function testUtf8Method()
+ public function testUtf8Method()
{
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'UTF-8';
$f = new xmlrpcmsg("tests.utf8methodname." . 'κόσμε', array(
new xmlrpcval('hello')
));
if ($v) {
$this->assertEquals('hello', $v->scalarval());
}
- }*/
+ PhpXmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1';
+ }
public function testAddingDoubles()
{
new xmlrpcval(true, 'boolean'),
new xmlrpcval(false, 'boolean'),
new xmlrpcval(1, 'boolean'),
- new xmlrpcval(0, 'boolean'),
- //new xmlrpcval('true', 'boolean'),
- //new xmlrpcval('false', 'boolean')
+ new xmlrpcval(0, 'boolean')
),
'array'
),));
));
$v = $this->send($f);
if ($v) {
- $this->assertEquals($v->scalarval(), true);
+ $this->assertEquals(true, $v->scalarval());
}
}
$f = new xmlrpcmsg('system.MethodHelp');
$f->payload = "<?xml version=\"1.0\"?><methodCall><methodName>validator1.echoStructTest</methodName><params><param><value><struct><member><name>','')); echo('gotcha!'); die(); //</name></member></struct></value></param></params></methodCall>";
$v = $this->send($f);
- //$v = $r->faultCode();
if ($v) {
$this->assertEquals(0, $v->structsize());
}
$cookies[$cookie] = (string)$cookies[$cookie];
}
$r = $this->client->send($f, $this->timeout, $this->method);
- $this->assertEquals($r->faultCode(), 0, 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
+ $this->assertEquals(0, $r->faultCode(), 'Error ' . $r->faultCode() . ' connecting to server: ' . $r->faultString());
if (!$r->faultCode()) {
$v = $r->value();
$v = php_xmlrpc_decode($v);
}
// on IIS and Apache getallheaders returns something slightly different...
- $this->assertEquals($v, $cookies);
+ $this->assertEquals($cookies, $v);
}
}
));
$v1 = $this->send($f);
$v2 = $this->send($f);
- //$v = $r->faultCode();
if ($v1 && $v2) {
- $this->assertEquals($v2, $v1);
+ $this->assertEquals($v1, $v2);
}
}
}
*/
function _runtests()
{
+ $unsafeMethods = array('testHttps', 'testCatchExceptions', 'testUtf8Method');
foreach(get_class_methods('LocalhostTest') as $method)
{
- if(strpos($method, 'test') === 0 && $method != 'testHttps' && $method != 'testCatchExceptions')
+ if(strpos($method, 'test') === 0 && !in_array($method, $unsafeMethods))
{
if (!isset(self::$failed_tests[$method]))
$this->$method();