]> granicus.if.org Git - php/commitdiff
Fixed bug #38004 Parameters in SoapServer are decoded twice
authorDmitry Stogov <dmitry@php.net>
Mon, 10 Jul 2006 07:21:41 +0000 (07:21 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 10 Jul 2006 07:21:41 +0000 (07:21 +0000)
NEWS
ext/soap/php_encoding.c
ext/soap/tests/bugs/bug38004.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug38004.wsdl [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 0dee09c07c361ae6b21281c37250c9055367ec7d..d48ed47008223443ee94a6869a2a92936ac1b749 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -82,6 +82,7 @@ PHP                                                                        NEWS
 
 - Fixed memory leaks in openssl streams context options. (Pierre)
 - Fixed handling of extremely long paths inside tempnam() function. (Ilia)
+- Fixed bug #38004 Parameters in SoapServer are decoded twice. (Dmitry)
 - Fixed bug #38003 (in classes inherited from MySQLi it's possible to call 
   private constructors from invalid context). (Tony)
 - Fixed bug #37987 (invalid return of file_exists() in safe mode). (Ilia)
index a46a62ccf2b11d7af35ecb58ca6ae793af5e7e0d..8d574c222583037c7e03227b19c4c565a5867ec6 100644 (file)
@@ -1353,11 +1353,12 @@ static zval *to_zval_object_ex(encodeTypePtr type, xmlNodePtr data, zend_class_e
                                                str_val = (*attr)->def;
                                        }
                                        if (str_val) {
+                                               zval zstr;
                                                xmlNodePtr dummy;
                                                zval *data;
 
-                                               dummy = xmlNewNode(NULL, "BOGUS");
-                                               xmlNodeSetContent(dummy, str_val);
+                                               ZVAL_STRING(&zstr, str_val, 0);
+                                               dummy = master_to_xml(get_conversion(IS_STRING), &zstr, SOAP_LITERAL, NULL);
                                                data = master_to_zval((*attr)->encode, dummy);
                                                xmlFreeNode(dummy);
                                                set_zval_property(ret, (*attr)->name, data TSRMLS_CC);
diff --git a/ext/soap/tests/bugs/bug38004.phpt b/ext/soap/tests/bugs/bug38004.phpt
new file mode 100755 (executable)
index 0000000..d187de3
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Bug #37278 (SOAP not respecting uri in __soapCall)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function Test($param) {
+       global $g;
+       $g = $param->strA."\n".$param->strB."\n";
+       return $g;
+}
+
+class TestSoapClient extends SoapClient {
+  function __construct($wsdl) {
+    parent::__construct($wsdl);
+    $this->server = new SoapServer($wsdl);
+    $this->server->addFunction('Test');
+  }
+
+  function __doRequest($request, $location, $action, $version) {
+    ob_start();
+    $this->server->handle($request);
+    $response = ob_get_contents();
+    ob_end_clean();
+    return $response;
+  }
+}
+
+$client = new TestSoapClient(dirname(__FILE__).'/bug38004.wsdl');
+$strA = 'test &amp; test';
+$strB = 'test & test';
+$res = $client->Test(array('strA'=>$strA, 'strB'=>$strB));
+print_r($res);
+print_r($g);
+?>
+--EXPECT--
+test &amp; test
+test & test
+test &amp; test
+test & test
diff --git a/ext/soap/tests/bugs/bug38004.wsdl b/ext/soap/tests/bugs/bug38004.wsdl
new file mode 100755 (executable)
index 0000000..c288135
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<definitions\r
+               xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"\r
+               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"\r
+               xmlns:s="http://www.w3.org/2001/XMLSchema"\r
+               xmlns:s0="http://test.pl"\r
+               targetNamespace="http://test.pl"\r
+               xmlns="http://schemas.xmlsoap.org/wsdl/"\r
+>\r
+       <types>\r
+               <s:schema elementFormDefault="qualified" targetNamespace="http://test.pl">\r
+                       <s:complexType name="Test">\r
+                               <s:attribute use="required" name="strA" type="s:string"/>\r
+                               <s:attribute use="required" name="strB" type="s:string"/>\r
+                       </s:complexType>\r
+                       <s:element type="s0:Test" name="Test"/>\r
+                       <s:element type="s:string" name="Ret"/>\r
+               </s:schema>\r
+       </types>\r
+\r
+       <message name="TestSoapIn">\r
+               <part name="parameters" element="s0:Test"/>\r
+       </message>\r
+       <message name="TestSoapOut">\r
+               <part name="parameters" element="s0:Ret"/>\r
+       </message>\r
+       <portType name="TestSoap">\r
+               <operation name="Test">\r
+                       <input message="s0:TestSoapIn"/>\r
+                       <output message="s0:TestSoapOut"/>\r
+               </operation>\r
+       </portType>\r
+       <binding name="TestSoap" type="s0:TestSoap">\r
+               <soap:binding transport="http://schemas.xmlsoap.org/soap/http"\r
+style="document"/>\r
+               <operation name="Test">\r
+                       <soap:operation soapAction="http:/Test/Test" style="document"/>\r
+                       <input>\r
+                               <soap:body use="literal"/>\r
+                       </input>\r
+                       <output>\r
+                               <soap:body use="literal"/>\r
+                       </output>\r
+               </operation>\r
+       </binding>\r
+       <service name="Test">\r
+               <port name="TestSoapPort" binding="s0:TestSoap">\r
+                       <soap:address location="http://localhost:8080/~dmitry/bug38004/server.php"/>\r
+               </port>\r
+       </service>\r
+</definitions>\r