diff options
author | Dmitry Stogov <dmitry@php.net> | 2006-07-10 07:41:33 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2006-07-10 07:41:33 +0000 |
commit | 795a482a48b4b72319d3c6911d021a45648da02b (patch) | |
tree | f220989052c54e143195b484d04279f2e7d8c7f8 | |
parent | 098d3d2b0274aafa8df56bd528ac36c4f80a977d (diff) | |
download | php-git-795a482a48b4b72319d3c6911d021a45648da02b.tar.gz |
Fixed bug #38005 (SoapFault faultstring doesn't follow encoding rules)
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/soap/php_packet_soap.c | 18 | ||||
-rw-r--r-- | ext/soap/soap.c | 24 | ||||
-rwxr-xr-x | ext/soap/tests/bugs/bug38005.phpt | 41 |
4 files changed, 66 insertions, 21 deletions
@@ -82,7 +82,9 @@ 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 #38005 (SoapFault faultstring doesn't follow encoding rules). + (Dmitry) +- 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) diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c index 4fb45a6413..92d9df5161 100644 --- a/ext/soap/php_packet_soap.c +++ b/ext/soap/php_packet_soap.c @@ -191,12 +191,16 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction tmp = get_node(fault->children,"faultstring"); if (tmp != NULL && tmp->children != NULL) { - faultstring = tmp->children->content; + zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); + faultstring = Z_STRVAL_P(zv); + FREE_ZVAL(zv); } tmp = get_node(fault->children,"faultactor"); if (tmp != NULL && tmp->children != NULL) { - faultactor = tmp->children->content; + zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); + faultactor = Z_STRVAL_P(zv); + FREE_ZVAL(zv); } tmp = get_node(fault->children,"detail"); @@ -217,7 +221,9 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction /* TODO: lang attribute */ tmp = get_node(tmp->children,"Text"); if (tmp != NULL && tmp->children != NULL) { - faultstring = tmp->children->content; + zval *zv = master_to_zval(get_conversion(IS_STRING), tmp); + faultstring = Z_STRVAL_P(zv); + FREE_ZVAL(zv); } } @@ -227,6 +233,12 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction } } add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details TSRMLS_CC); + if (faultstring) { + efree(faultstring); + } + if (faultactor) { + efree(faultactor); + } #ifdef ZEND_ENGINE_2 if (details) { details->refcount--; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index f8926da0ea..374447365e 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -3729,20 +3729,12 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function efree(str); } if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) { - int new_len; - xmlNodePtr node = xmlNewNode(NULL, "faultstring"); - char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); - xmlAddChild(param, node); - xmlNodeSetContentLen(node, str, new_len); - efree(str); + xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param); + xmlNodeSetName(node, "faultstring"); } if (zend_hash_find(prop, "faultactor", sizeof("faultactor"), (void**)&tmp) == SUCCESS) { - int new_len; - xmlNodePtr node = xmlNewNode(NULL, "faultactor"); - char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); - xmlAddChild(param, node); - xmlNodeSetContentLen(node, str, new_len); - efree(str); + xmlNodePtr node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, param); + xmlNodeSetName(node, "faultactor"); } detail_name = "detail"; } else { @@ -3760,12 +3752,10 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function efree(str); } if (zend_hash_find(prop, "faultstring", sizeof("faultstring"), (void**)&tmp) == SUCCESS) { - int new_len; xmlNodePtr node = xmlNewChild(param, ns, "Reason", NULL); - char *str = php_escape_html_entities(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), &new_len, 0, 0, NULL TSRMLS_CC); - node = xmlNewChild(node, ns, "Text", NULL); - xmlNodeSetContentLen(node, str, new_len); - efree(str); + node = master_to_xml(get_conversion(IS_STRING), *tmp, SOAP_LITERAL, node); + xmlNodeSetName(node, "Text"); + xmlSetNs(node, ns); } detail_name = SOAP_1_2_ENV_NS_PREFIX":Detail"; } diff --git a/ext/soap/tests/bugs/bug38005.phpt b/ext/soap/tests/bugs/bug38005.phpt new file mode 100755 index 0000000000..d15beccce5 --- /dev/null +++ b/ext/soap/tests/bugs/bug38005.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #38005 (SoapFault faultstring doesn't follow encoding rules) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +function Test($param) { + return new SoapFault('Test', 'This is our fault: Ä'); +} + +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(NULL, array( + 'encoding' => 'ISO-8859-1', + 'uri' => "test://", + 'location' => "test://", + 'soap_version'=>SOAP_1_2, + 'trace'=>1, + 'exceptions'=>0)); +$res = $client->Test(); +echo($res->faultstring."\n"); +echo($client->__getLastResponse()); +?> +--EXPECT-- +This is our fault: Ä +<?xml version="1.0" encoding="UTF-8"?> +<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>Test</env:Value></env:Code><env:Reason><env:Text>This is our fault: Ä</env:Text></env:Reason></env:Fault></env:Body></env:Envelope> |