]> granicus.if.org Git - php/commitdiff
Fixed bug #47273 (Encoding bug in SoapServer->fault)
authorDmitry Stogov <dmitry@php.net>
Wed, 26 Aug 2009 14:05:48 +0000 (14:05 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 26 Aug 2009 14:05:48 +0000 (14:05 +0000)
NEWS
ext/soap/soap.c
ext/soap/tests/bugs/bug47273.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 40c6c58724c52a37efdc5d78d5010603257aa4de..eee4f68e7c91c701b507597bcf6b0e492862fcf3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -146,6 +146,7 @@ PHP                                                                        NEWS
 - Fixed bug #47481 (natcasesort() does not sort extended ASCII characters
   correctly). (Herman Radtke)
 - Fixed bug #47351 (Memory leak in DateTime). (Derick, Tobias John)
+- Fixed bug #47273 (Encoding bug in SoapServer->fault). (Dmitry)
 - Fixed bug #46682 (touch() afield returns different values on windows).
   (Pierre)
 - Fixed bug #45905 (imagefilledrectangle() clipping error).
index fdd983993f8dc07eb24a71033aa36cb3b73b2bd0..59d13fa52763eff81afcabe2ea27077f98c3a205 100644 (file)
@@ -2128,8 +2128,13 @@ PHP_METHOD(SoapServer, fault)
        char *code, *string, *actor=NULL, *name=NULL;
        int code_len, string_len, actor_len = 0, name_len = 0;
        zval* details = NULL;
+       soapServicePtr service;
+       xmlCharEncodingHandlerPtr old_encoding;
 
        SOAP_SERVER_BEGIN_CODE();
+       FETCH_THIS_SERVICE(service);
+       old_encoding = SOAP_GLOBAL(encoding);
+       SOAP_GLOBAL(encoding) = service->encoding;
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|szs",
            &code, &code_len, &string, &string_len, &actor, &actor_len, &details,
@@ -2138,6 +2143,8 @@ PHP_METHOD(SoapServer, fault)
        }
 
        soap_server_fault(code, string, actor, details, name TSRMLS_CC);
+
+       SOAP_GLOBAL(encoding) = old_encoding;
        SOAP_SERVER_END_CODE();
 }
 /* }}} */
diff --git a/ext/soap/tests/bugs/bug47273.phpt b/ext/soap/tests/bugs/bug47273.phpt
new file mode 100644 (file)
index 0000000..174948f
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+Bug #47273 (Encoding bug in SoapServer->fault)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+unicode.script_encoding=ISO-8859-1
+unicode.output_encoding=ISO-8859-1
+--FILE--
+<?php
+$request1 = <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test1/></SOAP-ENV:Body></SOAP-ENV:Envelope>
+EOF;
+$request2 = <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test2/></SOAP-ENV:Body></SOAP-ENV:Envelope>
+EOF;
+
+class SoapFaultTest
+{
+    public function test1() {
+       //  Test #1
+        return 'Test #1 exception with some special chars: Äßö';
+    }
+    public function test2() {    
+        //  Test #2
+       //throw new SoapFault('Server', 'Test #2 exception with some special chars: Äßö');
+        throw new Exception('Test #2 exception with some special chars: Äßö');
+    }
+}
+
+$server = new SoapServer(null, array(
+'uri' => "http://127.0.0.1:8080/test/",
+'encoding' => 'ISO-8859-1'));
+$server->setClass('SoapFaultTest');
+
+try {
+       $server->handle($request1);
+} catch (Exception $e) {
+       $server->fault("Sender", $e->getMessage());
+}
+try {
+        $server->handle($request2);
+} catch (Exception $e) {
+        $server->fault("Sender", $e->getMessage());
+}
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://127.0.0.1:8080/test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test1Response><return xsi:type="xsd:string">Test #1 exception with some special chars: Ã\84Ã\9fö</return></ns1:test1Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Test #2 exception with some special chars: Ã\84Ã\9fö</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
+