Add test for latest fixes and update NEWS
authorgggeek <giunta.gaetano@gmail.com>
Sat, 11 Apr 2015 23:09:16 +0000 (00:09 +0100)
committergggeek <giunta.gaetano@gmail.com>
Sat, 11 Apr 2015 23:09:16 +0000 (00:09 +0100)
NEWS
tests/1ParsingBugsTest.php

diff --git a/NEWS b/NEWS
index ee0d49a..d54c51f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -38,7 +38,13 @@ 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
+* fixed: the debugger would fail sending a request with ISO-8859-1 payload (it missed the character set declaration)
+
+* fixed: the server would fail to decode a request with ISO-8859-1 payload and character set declaration in the xml prologue only
+
+* fixed: the client would fail to decode a response with ISO-8859-1 payload and character set declaration in the xml prologue only
+
+* fixed: the function decode_xml() would not decode an xml with character set declaration in the xml prologue
 
 
 XML-RPC for PHP version 3.0.0 - 2014/6/15
index 949130f..33915ca 100644 (file)
@@ -421,6 +421,7 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $v = $r->value();
         $v = $v['content'];
         $this->assertEquals("������", $v);
+
         $f = '<?xml version="1.0" encoding="utf-8"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
 <member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . utf8_encode('������') . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
 ';
@@ -428,6 +429,36 @@ and there they were.</value></member><member><name>postid</name><value>7414222</
         $v = $r->value();
         $v = $v['content'];
         $this->assertEquals("������", $v);
+
+        $r = php_xmlrpc_decode_xml($f);
+        $v = $r->value();
+        $v = $v->structmem('content')->scalarval();
+        $this->assertEquals("������", $v);
+    }
+
+    public function testLatin1Response()
+    {
+        $s = new xmlrpcmsg('dummy');
+        $f = "HTTP/1.1 200 OK\r\nContent-type: text/xml; charset=ISO-8859-1\r\n\r\n" . '<?xml version="1.0"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . '������' . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+';
+        $r = $s->parseResponse($f, false, 'phpvals');
+        $v = $r->value();
+        $v = $v['content'];
+        $this->assertEquals("������", $v);
+
+        $f = '<?xml version="1.0" encoding="iso-8859-1"?><methodResponse><params><param><value><struct><member><name>userid</name><value>311127</value></member>
+<member><name>dateCreated</name><value><dateTime.iso8601>20011126T09:17:52</dateTime.iso8601></value></member><member><name>content</name><value>' . '������' . '</value></member><member><name>postid</name><value>7414222</value></member></struct></value></param></params></methodResponse>
+';
+        $r = $s->parseResponse($f, false, 'phpvals');
+        $v = $r->value();
+        $v = $v['content'];
+        $this->assertEquals("������", $v);
+
+        $r = php_xmlrpc_decode_xml($f);
+        $v = $r->value();
+        $v = $v->structmem('content')->scalarval();
+        $this->assertEquals("������", $v);
     }
 
     public function testUTF8IntString()