From 22223dbd36afb365b42d8023e2434124e8772a6a Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 1 Oct 2008 08:43:21 +0000 Subject: [PATCH] Fixed bug #43045 (SOAP encoding violation on "INF" for type double/float) --- ext/soap/php_encoding.c | 10 +++++- ext/soap/tests/bugs/bug43045.phpt | 52 +++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 ext/soap/tests/bugs/bug43045.phpt diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 7fa330da83a..471d709de5a 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -944,7 +944,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 00000000000..a32acfe0ead --- /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)