]> granicus.if.org Git - php/commitdiff
Fixed bug #38067 (Parameters are not decoded from utf-8 when using encoding option)
authorDmitry Stogov <dmitry@php.net>
Wed, 12 Jul 2006 08:59:40 +0000 (08:59 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 12 Jul 2006 08:59:40 +0000 (08:59 +0000)
NEWS
ext/soap/php_encoding.c
ext/soap/tests/bugs/bug38067.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug38067.wsdl [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index 93be7adf055d17de959bfae766d02f7702bfe843..77676d0f43252f50408dd8e8f0cacc16f9c43a5e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -82,6 +82,8 @@ PHP                                                                        NEWS
 
 - Fixed memory leaks in openssl streams context options. (Pierre)
 - Fixed handling of extremely long paths inside tempnam() function. (Ilia)
+- Fixed bug #38067 (Parameters are not decoded from utf-8 when using encoding
+  option). (Dmitry)
 - Fixed bug #38055 (Wrong interpretation of boolean parameters). (Dmitry)
 - Fixed bug #38019 (segfault extending mysqli class). (Dmitry)
 - Fixed bug #38005 (SoapFault faultstring doesn't follow encoding rules).
index c95c1aaeb975de669abec355dd0d0bec3c04f5a9..52f784897d089fff1b9f2af1e601a511889800f7 100644 (file)
@@ -1346,12 +1346,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;
+                                               xmlNodePtr dummy, text;
                                                zval *data;
 
-                                               ZVAL_STRING(&zstr, str_val, 0);
-                                               dummy = master_to_xml(get_conversion(IS_STRING), &zstr, SOAP_LITERAL, NULL);
+                                               dummy = xmlNewNode(NULL, BAD_CAST("BOGUS"));
+                                               text = xmlNewText(BAD_CAST(str_val));
+                                               xmlAddChild(dummy, text);
                                                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/bug38067.phpt b/ext/soap/tests/bugs/bug38067.phpt
new file mode 100755 (executable)
index 0000000..9c0cbb4
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+Bug #38067 (Parameters are not decoded from utf-8 when using encoding option)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+function Test($param) {
+       global $g;
+       $g = $param->str;
+       return $g;
+}
+
+class TestSoapClient extends SoapClient {
+  function __construct($wsdl, $opt) {
+    parent::__construct($wsdl, $opt);
+    $this->server = new SoapServer($wsdl, $opt);
+    $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__).'/bug38067.wsdl',
+       array('encoding' => 'ISO-8859-1'));
+$str = 'test: Ä';
+$res = $client->Test(array('str'=>$str));
+echo $str."\n";
+echo $res."\n";
+echo $g."\n";
+?>
+--EXPECT--
+test: Ä
+test: Ä
+test: Ä
diff --git a/ext/soap/tests/bugs/bug38067.wsdl b/ext/soap/tests/bugs/bug38067.wsdl
new file mode 100755 (executable)
index 0000000..beb9fc2
--- /dev/null
@@ -0,0 +1,48 @@
+<?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
+       <types>\r
+               <s:schema elementFormDefault="qualified" targetNamespace="http://test.pl">\r
+                       <s:complexType name="Test">\r
+                               <s:attribute use="required" name="str" 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" 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/server.php"/>\r
+               </port>\r
+       </service>\r
+</definitions>\r