From: Dmitry Stogov Date: Mon, 10 Jul 2006 07:41:33 +0000 (+0000) Subject: Fixed bug #38005 (SoapFault faultstring doesn't follow encoding rules) X-Git-Tag: php-5.2.0RC1~150 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=795a482a48b4b72319d3c6911d021a45648da02b;p=php Fixed bug #38005 (SoapFault faultstring doesn't follow encoding rules) --- diff --git a/NEWS b/NEWS index d48ed47008..32098c9ae4 100644 --- a/NEWS +++ b/NEWS @@ -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-- + +--FILE-- +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: Ä + +TestThis is our fault: Ä