From: Dmitry Stogov Date: Wed, 1 Oct 2008 08:42:26 +0000 (+0000) Subject: Fixed bug #43045 (SOAP encoding violation on "INF" for type double/float) X-Git-Tag: php-5.2.7RC1~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f289abf4d7f59557e90b6fa2d3df8f9e18ecf2af;p=php Fixed bug #43045 (SOAP encoding violation on "INF" for type double/float) --- diff --git a/NEWS b/NEWS index 14741cb969..5c034345d9 100644 --- a/NEWS +++ b/NEWS @@ -133,6 +133,8 @@ PHP NEWS (Jani) - Fixed bug #42318 (problem with nm on AIX, not finding object files). (Dmitry) - Fixed bug #41348 (OCI8: allow compilation with Oracle 8.1). (Chris Jones) +- Fixed bug #43045 (SOAP encoding violation on "INF" for type double/float). + (Dmitry) 01 May 2008, PHP 5.2.6 - Fixed two possible crashes inside posix extension (Tony) diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 6ad0db1ccd..6df653570b 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1014,7 +1014,15 @@ static zval *to_zval_double(encodeTypePtr type, xmlNodePtr data) Z_DVAL_P(ret) = dval; break; default: - soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); + if (strncasecmp((char*)data->children->content, "NaN", sizeof("NaN")-1) == 0) { + ZVAL_DOUBLE(ret, php_get_nan()); + } else if (strncasecmp((char*)data->children->content, "INF", sizeof("INF")-1) == 0) { + ZVAL_DOUBLE(ret, php_get_inf()); + } else if (strncasecmp((char*)data->children->content, "-INF", sizeof("-INF")-1) == 0) { + ZVAL_DOUBLE(ret, -php_get_inf()); + } else { + soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); + } } } else { soap_error0(E_ERROR, "Encoding: Violation of encoding rules"); diff --git a/ext/soap/tests/bugs/bug43045.phpt b/ext/soap/tests/bugs/bug43045.phpt new file mode 100644 index 0000000000..a32acfe0ea --- /dev/null +++ b/ext/soap/tests/bugs/bug43045.phpt @@ -0,0 +1,52 @@ +--TEST-- +Bug #43045i (SOAP encoding violation on "INF" for type double/float) +--SKIPIF-- + +--FILE-- +server = new SoapServer($wsdl, $options); + $this->server->addFunction('test'); + } + function __doRequest($request, $location, $action, $version, $one_way = 0) { + ob_start(); + $this->server->handle($request); + $response = ob_get_contents(); + ob_end_clean(); + return $response; + + echo $request; + return ' + + +INF + + +'; + } +} +$client = new TestSoapClient(NULL, array( + "location" => "test://", + "uri" => 'urn:TestSOAP', + "style" => SOAP_RPC, + "use" => SOAP_ENCODED + )); +var_dump($client->test(0.1)); +var_dump($client->test(NAN)); +var_dump($response = $client->test(INF)); +var_dump($response = $client->test(-INF)); +--EXPECT-- +float(0.1) +float(NAN) +float(INF) +float(-INF)