dmitry                                   Wed, 26 Aug 2009 14:05:48 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=287746

Log:
Fixed bug #47273 (Encoding bug in SoapServer->fault)

Bug: http://bugs.php.net/47273 (Assigned) Encoding bug in SoapServer->fault
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/soap/soap.c
    A   php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug47273.phpt
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/soap/soap.c
    A   php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug47273.phpt
    A   php/php-src/trunk/ext/soap/tests/bugs/bug47273.phpt

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS	2009-08-26 13:59:16 UTC (rev 287745)
+++ php/php-src/branches/PHP_5_2/NEWS	2009-08-26 14:05:48 UTC (rev 287746)
@@ -11,6 +11,7 @@
 - Fixed bug #49236 (Missing PHP_SUBST(PDO_MYSQL_SHARED_LIBADD)). (Jani)
 - Fixed bug #49144 (Import of schema from different host transmits original
   authentication details). (Dmitry)
+- Fixed bug #47273 (Encoding bug in SoapServer->fault). (Dmitry)
 - Fixed bug #28038  (Sent incorrect RCPT TO commands to SMTP server) (Garrett)



Modified: php/php-src/branches/PHP_5_2/ext/soap/soap.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/soap/soap.c	2009-08-26 13:59:16 UTC (rev 287745)
+++ php/php-src/branches/PHP_5_2/ext/soap/soap.c	2009-08-26 14:05:48 UTC (rev 287746)
@@ -1956,8 +1956,13 @@
 	char *code, *string, *actor=NULL, *name=NULL;
 	int code_len, string_len, actor_len, name_len;
 	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,
@@ -1966,6 +1971,8 @@
 	}

 	soap_server_fault(code, string, actor, details, name TSRMLS_CC);
+
+	SOAP_GLOBAL(encoding) = old_encoding;
 	SOAP_SERVER_END_CODE();
 }
 /* }}} */

Added: php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug47273.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug47273.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/soap/tests/bugs/bug47273.phpt	2009-08-26 14:05:48 UTC (rev 287746)
@@ -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: Äßö</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: Äßö</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
+

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2009-08-26 13:59:16 UTC (rev 287745)
+++ php/php-src/branches/PHP_5_3/NEWS	2009-08-26 14:05:48 UTC (rev 287746)
@@ -146,6 +146,7 @@
 - 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).

Modified: php/php-src/branches/PHP_5_3/ext/soap/soap.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/soap/soap.c	2009-08-26 13:59:16 UTC (rev 287745)
+++ php/php-src/branches/PHP_5_3/ext/soap/soap.c	2009-08-26 14:05:48 UTC (rev 287746)
@@ -2128,8 +2128,13 @@
 	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 @@
 	}

 	soap_server_fault(code, string, actor, details, name TSRMLS_CC);
+
+	SOAP_GLOBAL(encoding) = old_encoding;
 	SOAP_SERVER_END_CODE();
 }
 /* }}} */

Added: php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug47273.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug47273.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/soap/tests/bugs/bug47273.phpt	2009-08-26 14:05:48 UTC (rev 287746)
@@ -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: Äßö</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: Äßö</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
+

Added: php/php-src/trunk/ext/soap/tests/bugs/bug47273.phpt
===================================================================
--- php/php-src/trunk/ext/soap/tests/bugs/bug47273.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/soap/tests/bugs/bug47273.phpt	2009-08-26 14:05:48 UTC (rev 287746)
@@ -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: Äßö</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: Äßö</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
+
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to