dmitry Mon Dec 18 14:39:39 2006 UTC
Modified files:
/php-src/ext/soap php_encoding.c
/php-src/ext/soap/tests/bugs bug39832.phpt bug39832.wsdl
Log:
Fixed bug #39832 (SOAP Server: parameter not matching the WSDL specified type
are set to 0)
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_encoding.c?r1=1.147&r2=1.148&diff_format=u
Index: php-src/ext/soap/php_encoding.c
diff -u php-src/ext/soap/php_encoding.c:1.147
php-src/ext/soap/php_encoding.c:1.148
--- php-src/ext/soap/php_encoding.c:1.147 Fri Nov 10 15:05:38 2006
+++ php-src/ext/soap/php_encoding.c Mon Dec 18 14:39:39 2006
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_encoding.c,v 1.147 2006/11/10 15:05:38 dmitry Exp $ */
+/* $Id: php_encoding.c,v 1.148 2006/12/18 14:39:39 dmitry Exp $ */
#include <time.h>
@@ -666,9 +666,15 @@
if (data->children->type == XML_TEXT_NODE &&
data->children->next == NULL) {
whiteSpace_collapse(data->children->content);
str = (char*)php_base64_decode(data->children->content,
strlen((char*)data->children->content), &str_len);
+ if (!str) {
+ soap_error0(E_ERROR, "Encoding: Violation of
encoding rules");
+ }
ZVAL_STRINGL(ret, str, str_len, 0);
} else if (data->children->type == XML_CDATA_SECTION_NODE &&
data->children->next == NULL) {
str = (char*)php_base64_decode(data->children->content,
strlen((char*)data->children->content), &str_len);
+ if (!str) {
+ soap_error0(E_ERROR, "Encoding: Violation of
encoding rules");
+ }
ZVAL_STRINGL(ret, str, str_len, 0);
} else {
soap_error0(E_ERROR, "Encoding: Violation of encoding
rules");
@@ -705,6 +711,8 @@
str[i] = (c - 'a' + 10) << 4;
} else if (c >= 'A' && c <= 'F') {
str[i] = (c - 'A' + 10) << 4;
+ } else {
+ soap_error0(E_ERROR, "Encoding: Violation of
encoding rules");
}
c = data->children->content[j++];
if (c >= '0' && c <= '9') {
@@ -713,6 +721,8 @@
str[i] |= c - 'a' + 10;
} else if (c >= 'A' && c <= 'F') {
str[i] |= c - 'A' + 10;
+ } else {
+ soap_error0(E_ERROR, "Encoding: Violation of
encoding rules");
}
}
str[str_len] = '\0';
@@ -825,8 +835,22 @@
if (data && data->children) {
if (data->children->type == XML_TEXT_NODE &&
data->children->next == NULL) {
+ long lval;
+ double dval;
+
whiteSpace_collapse(data->children->content);
- ZVAL_DOUBLE(ret, atof((char*)data->children->content));
+ switch
(is_numeric_string((char*)data->children->content,
strlen((char*)data->children->content), &lval, &dval, 0)) {
+ case IS_LONG:
+ Z_TYPE_P(ret) = IS_DOUBLE;
+ Z_DVAL_P(ret) = lval;
+ break;
+ case IS_DOUBLE:
+ Z_TYPE_P(ret) = IS_DOUBLE;
+ Z_DVAL_P(ret) = dval;
+ break;
+ default:
+ soap_error0(E_ERROR, "Encoding:
Violation of encoding rules");
+ }
} else {
soap_error0(E_ERROR, "Encoding: Violation of encoding
rules");
}
@@ -844,14 +868,21 @@
if (data && data->children) {
if (data->children->type == XML_TEXT_NODE &&
data->children->next == NULL) {
+ long lval;
+ double dval;
+
whiteSpace_collapse(data->children->content);
errno = 0;
- ret->value.lval =
strtol((char*)data->children->content, NULL, 0);
- if (errno == ERANGE) { /* overflow */
- ret->value.dval =
zend_strtod((char*)data->children->content, NULL);
- ret->type = IS_DOUBLE;
- } else {
- ret->type = IS_LONG;
+
+ switch ((Z_TYPE_P(ret) =
is_numeric_string((char*)data->children->content,
strlen((char*)data->children->content), &lval, &dval, 0))) {
+ case IS_LONG:
+ Z_LVAL_P(ret) = lval;
+ break;
+ case IS_DOUBLE:
+ Z_DVAL_P(ret) = dval;
+ break;
+ default:
+ soap_error0(E_ERROR, "Encoding:
Violation of encoding rules");
}
} else {
soap_error0(E_ERROR, "Encoding: Violation of encoding
rules");
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug39832.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug39832.phpt
diff -u /dev/null php-src/ext/soap/tests/bugs/bug39832.phpt:1.2
--- /dev/null Mon Dec 18 14:39:39 2006
+++ php-src/ext/soap/tests/bugs/bug39832.phpt Mon Dec 18 14:39:39 2006
@@ -0,0 +1,29 @@
+--TEST--
+Bug #39832 (SOAP Server: parameter not matching the WSDL specified type are
set to 0)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--INI--
+soap.wsdl_cache_enabled=0
+--FILE--
+<?php
+$HTTP_RAW_POST_DATA = <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://test.pl"><SOAP-ENV:Body>
+<SOAP-ENV:Test>
+<parameters priority="high">
+<ns1:NetworkErrorCode>1</ns1:NetworkErrorCode>
+</parameters>
+</SOAP-ENV:Test></SOAP-ENV:Body></SOAP-ENV:Envelope>
+EOF;
+
+function Test($x) {
+ return $x->priority;
+}
+
+$x = new SoapServer(dirname(__FILE__)."/bug39832.wsdl");
+$x->addFunction("Test");
+$x->handle();
+?>
+--EXPECT--
+<?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>SOAP-ENV:Server</faultcode><faultstring>SOAP-ERROR:
Encoding: Violation of encoding
rules</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/tests/bugs/bug39832.wsdl?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/soap/tests/bugs/bug39832.wsdl
diff -u /dev/null php-src/ext/soap/tests/bugs/bug39832.wsdl:1.2
--- /dev/null Mon Dec 18 14:39:39 2006
+++ php-src/ext/soap/tests/bugs/bug39832.wsdl Mon Dec 18 14:39:39 2006
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:s="http://www.w3.org/2001/XMLSchema"
+ xmlns:s0="http://test.pl"
+ targetNamespace="http://test.pl"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <s:schema elementFormDefault="qualified"
targetNamespace="http://test.pl">
+ <s:complexType name="MessageInfoType">
+ <s:sequence>
+ <s:element name="NetworkErrorCode"
type="s:integer" minOccurs="0"/>
+ </s:sequence>
+ <s:attribute name="priority" type="s0:PriorityType"/>
+ </s:complexType>
+ <s:simpleType name="PriorityType">
+ <s:restriction base="s:integer">
+ <s:minInclusive value="0"/>
+ <s:maxInclusive value="3"/>
+ </s:restriction>
+ </s:simpleType>
+ </s:schema>
+ </types>
+
+ <message name="TestSoapIn">
+ <part name="parameters" type="s0:MessageInfoType" />
+ </message>
+ <message name="TestSoapOut">
+ <part name="parameters" type="s:string" />
+ </message>
+ <portType name="TestSoap">
+ <operation name="Test">
+ <input message="s0:TestSoapIn"/>
+ <output message="s0:TestSoapOut"/>
+ </operation>
+ </portType>
+ <binding name="TestSoap" type="s0:TestSoap">
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document"/>
+ <operation name="Test">
+ <soap:operation soapAction="http:/Test/Test"
style="rpc"/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="Test">
+ <port name="TestSoapPort" binding="s0:TestSoap">
+ <soap:address location="http://localhost/server.php"/>
+ </port>
+ </service>
+</definitions>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php