Skip to content

Commit 2a13304

Browse files
committed
Fix GH-8538: SoapClient may strip parts of nmtokens
When stripping the namespace prefix, we can assume that this does not contain any colons, while the rest of the name may contain colons. Hence we must not use `strrchr()` but rather `strchr()` instead. Closes GH-8543.
1 parent f0480eb commit 2a13304

File tree

4 files changed

+346
-1
lines changed

4 files changed

+346
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ PHP NEWS
2424
- Soap:
2525
. Fixed bug GH-8578 (Error on wrong parameter on SoapHeader constructor).
2626
(robertnisipeanu)
27+
. Fixed bug GH-8538 (SoapClient may strip parts of nmtokens). (cmb)
2728

2829
- SPL:
2930
. Fixed bug GH-8235 (iterator_count() may run indefinitely). (cmb)

ext/soap/php_sdl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
883883
soap_error0(E_ERROR, "Parsing WSDL: Missing 'type' attribute for <binding>");
884884
}
885885

886-
ctype = strrchr((char*)type->children->content,':');
886+
ctype = strchr((char*)type->children->content,':');
887887
if (ctype == NULL) {
888888
ctype = (char*)type->children->content;
889889
} else {

ext/soap/tests/gh8538.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug GH-8538 (SoapClient may strip parts of nmtokens)
3+
--SKIPIF--
4+
<?php require_once("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
$client = new SoapClient(__DIR__ . "/gh8538.wsdl");
8+
var_dump($client->__getFunctions());
9+
?>
10+
--EXPECT--
11+
array(9) {
12+
[0]=>
13+
string(71) "reportHealthViewResponse reportHealthView(reportHealthView $parameters)"
14+
[1]=>
15+
string(59) "reportPolicyResponse reportPolicy(reportPolicy $parameters)"
16+
[2]=>
17+
string(56) "queryPolicyResponse queryPolicy(queryPolicy $parameters)"
18+
[3]=>
19+
string(59) "reportConfigResponse reportConfig(reportConfig $parameters)"
20+
[4]=>
21+
string(56) "reportEventResponse reportEvent(reportEvent $parameters)"
22+
[5]=>
23+
string(53) "reportViewResponse reportView(reportView $parameters)"
24+
[6]=>
25+
string(56) "queryConfigResponse queryConfig(queryConfig $parameters)"
26+
[7]=>
27+
string(50) "queryViewResponse queryView(queryView $parameters)"
28+
[8]=>
29+
string(50) "reportLogResponse reportLog(reportLog $parameters)"
30+
}

ext/soap/tests/gh8538.wsdl

Lines changed: 314 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://wssmcommupper/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="WSSmCommUpperImplService" targetNamespace="http://wssmcommupper/">
3+
<wsdl:types>
4+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://wssmcommupper/" version="1.0">
5+
<xs:element name="queryConfig" type="tns:queryConfig" />
6+
<xs:element name="queryConfigResponse" type="tns:queryConfigResponse" />
7+
<xs:element name="queryPolicy" type="tns:queryPolicy" />
8+
<xs:element name="queryPolicyResponse" type="tns:queryPolicyResponse" />
9+
<xs:element name="queryView" type="tns:queryView" />
10+
<xs:element name="queryViewResponse" type="tns:queryViewResponse" />
11+
<xs:element name="reportConfig" type="tns:reportConfig" />
12+
<xs:element name="reportConfigResponse" type="tns:reportConfigResponse" />
13+
<xs:element name="reportEvent" type="tns:reportEvent" />
14+
<xs:element name="reportEventResponse" type="tns:reportEventResponse" />
15+
<xs:element name="reportHealthView" type="tns:reportHealthView" />
16+
<xs:element name="reportHealthViewResponse" type="tns:reportHealthViewResponse" />
17+
<xs:element name="reportLog" type="tns:reportLog" />
18+
<xs:element name="reportLogResponse" type="tns:reportLogResponse" />
19+
<xs:element name="reportPolicy" type="tns:reportPolicy" />
20+
<xs:element name="reportPolicyResponse" type="tns:reportPolicyResponse" />
21+
<xs:element name="reportView" type="tns:reportView" />
22+
<xs:element name="reportViewResponse" type="tns:reportViewResponse" />
23+
<xs:complexType name="reportHealthView">
24+
<xs:sequence>
25+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
26+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
27+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
28+
</xs:sequence>
29+
</xs:complexType>
30+
<xs:complexType name="reportHealthViewResponse">
31+
<xs:sequence>
32+
<xs:element name="return" type="xs:int" />
33+
</xs:sequence>
34+
</xs:complexType>
35+
<xs:complexType name="reportPolicy">
36+
<xs:sequence>
37+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
38+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
39+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
40+
</xs:sequence>
41+
</xs:complexType>
42+
<xs:complexType name="reportPolicyResponse">
43+
<xs:sequence>
44+
<xs:element name="return" type="xs:int" />
45+
</xs:sequence>
46+
</xs:complexType>
47+
<xs:complexType name="queryPolicy">
48+
<xs:sequence>
49+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
50+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
51+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
52+
</xs:sequence>
53+
</xs:complexType>
54+
<xs:complexType name="queryPolicyResponse">
55+
<xs:sequence>
56+
<xs:element minOccurs="0" name="return" type="xs:string" />
57+
</xs:sequence>
58+
</xs:complexType>
59+
<xs:complexType name="reportConfig">
60+
<xs:sequence>
61+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
62+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
63+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
64+
</xs:sequence>
65+
</xs:complexType>
66+
<xs:complexType name="reportConfigResponse">
67+
<xs:sequence>
68+
<xs:element name="return" type="xs:int" />
69+
</xs:sequence>
70+
</xs:complexType>
71+
<xs:complexType name="reportEvent">
72+
<xs:sequence>
73+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
74+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
75+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
76+
</xs:sequence>
77+
</xs:complexType>
78+
<xs:complexType name="reportEventResponse">
79+
<xs:sequence>
80+
<xs:element name="return" type="xs:int" />
81+
</xs:sequence>
82+
</xs:complexType>
83+
<xs:complexType name="reportView">
84+
<xs:sequence>
85+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
86+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
87+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
88+
</xs:sequence>
89+
</xs:complexType>
90+
<xs:complexType name="reportViewResponse">
91+
<xs:sequence>
92+
<xs:element name="return" type="xs:int" />
93+
</xs:sequence>
94+
</xs:complexType>
95+
<xs:complexType name="queryConfig">
96+
<xs:sequence>
97+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
98+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
99+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
100+
</xs:sequence>
101+
</xs:complexType>
102+
<xs:complexType name="queryConfigResponse">
103+
<xs:sequence>
104+
<xs:element minOccurs="0" name="return" type="xs:string" />
105+
</xs:sequence>
106+
</xs:complexType>
107+
<xs:complexType name="queryView">
108+
<xs:sequence>
109+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
110+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
111+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
112+
</xs:sequence>
113+
</xs:complexType>
114+
<xs:complexType name="queryViewResponse">
115+
<xs:sequence>
116+
<xs:element minOccurs="0" name="return" type="xs:string" />
117+
</xs:sequence>
118+
</xs:complexType>
119+
<xs:complexType name="reportLog">
120+
<xs:sequence>
121+
<xs:element minOccurs="0" name="arg0" type="xs:string" />
122+
<xs:element minOccurs="0" name="arg1" type="xs:string" />
123+
<xs:element minOccurs="0" name="arg2" type="xs:string" />
124+
</xs:sequence>
125+
</xs:complexType>
126+
<xs:complexType name="reportLogResponse">
127+
<xs:sequence>
128+
<xs:element name="return" type="xs:int" />
129+
</xs:sequence>
130+
</xs:complexType>
131+
</xs:schema>
132+
</wsdl:types>
133+
<wsdl:message name="reportPolicy">
134+
<wsdl:part element="tns:reportPolicy" name="parameters" />
135+
</wsdl:message>
136+
<wsdl:message name="reportEvent">
137+
<wsdl:part element="tns:reportEvent" name="parameters" />
138+
</wsdl:message>
139+
<wsdl:message name="reportView">
140+
<wsdl:part element="tns:reportView" name="parameters" />
141+
</wsdl:message>
142+
<wsdl:message name="queryPolicyResponse">
143+
<wsdl:part element="tns:queryPolicyResponse" name="parameters" />
144+
</wsdl:message>
145+
<wsdl:message name="reportEventResponse">
146+
<wsdl:part element="tns:reportEventResponse" name="parameters" />
147+
</wsdl:message>
148+
<wsdl:message name="queryView">
149+
<wsdl:part element="tns:queryView" name="parameters" />
150+
</wsdl:message>
151+
<wsdl:message name="reportLog">
152+
<wsdl:part element="tns:reportLog" name="parameters" />
153+
</wsdl:message>
154+
<wsdl:message name="reportViewResponse">
155+
<wsdl:part element="tns:reportViewResponse" name="parameters" />
156+
</wsdl:message>
157+
<wsdl:message name="reportHealthView">
158+
<wsdl:part element="tns:reportHealthView" name="parameters" />
159+
</wsdl:message>
160+
<wsdl:message name="reportConfigResponse">
161+
<wsdl:part element="tns:reportConfigResponse" name="parameters" />
162+
</wsdl:message>
163+
<wsdl:message name="reportHealthViewResponse">
164+
<wsdl:part element="tns:reportHealthViewResponse" name="parameters" />
165+
</wsdl:message>
166+
<wsdl:message name="reportLogResponse">
167+
<wsdl:part element="tns:reportLogResponse" name="parameters" />
168+
</wsdl:message>
169+
<wsdl:message name="queryPolicy">
170+
<wsdl:part element="tns:queryPolicy" name="parameters" />
171+
</wsdl:message>
172+
<wsdl:message name="reportConfig">
173+
<wsdl:part element="tns:reportConfig" name="parameters" />
174+
</wsdl:message>
175+
<wsdl:message name="queryConfig">
176+
<wsdl:part element="tns:queryConfig" name="parameters" />
177+
</wsdl:message>
178+
<wsdl:message name="reportPolicyResponse">
179+
<wsdl:part element="tns:reportPolicyResponse" name="parameters" />
180+
</wsdl:message>
181+
<wsdl:message name="queryViewResponse">
182+
<wsdl:part element="tns:queryViewResponse" name="parameters" />
183+
</wsdl:message>
184+
<wsdl:message name="queryConfigResponse">
185+
<wsdl:part element="tns:queryConfigResponse" name="parameters" />
186+
</wsdl:message>
187+
<wsdl:portType name="http:wssmcommupper">
188+
<wsdl:operation name="reportHealthView">
189+
<wsdl:input message="tns:reportHealthView" name="reportHealthView" />
190+
<wsdl:output message="tns:reportHealthViewResponse" name="reportHealthViewResponse" />
191+
</wsdl:operation>
192+
<wsdl:operation name="reportPolicy">
193+
<wsdl:input message="tns:reportPolicy" name="reportPolicy" />
194+
<wsdl:output message="tns:reportPolicyResponse" name="reportPolicyResponse" />
195+
</wsdl:operation>
196+
<wsdl:operation name="queryPolicy">
197+
<wsdl:input message="tns:queryPolicy" name="queryPolicy" />
198+
<wsdl:output message="tns:queryPolicyResponse" name="queryPolicyResponse" />
199+
</wsdl:operation>
200+
<wsdl:operation name="reportConfig">
201+
<wsdl:input message="tns:reportConfig" name="reportConfig" />
202+
<wsdl:output message="tns:reportConfigResponse" name="reportConfigResponse" />
203+
</wsdl:operation>
204+
<wsdl:operation name="reportEvent">
205+
<wsdl:input message="tns:reportEvent" name="reportEvent" />
206+
<wsdl:output message="tns:reportEventResponse" name="reportEventResponse" />
207+
</wsdl:operation>
208+
<wsdl:operation name="reportView">
209+
<wsdl:input message="tns:reportView" name="reportView" />
210+
<wsdl:output message="tns:reportViewResponse" name="reportViewResponse" />
211+
</wsdl:operation>
212+
<wsdl:operation name="queryConfig">
213+
<wsdl:input message="tns:queryConfig" name="queryConfig" />
214+
<wsdl:output message="tns:queryConfigResponse" name="queryConfigResponse" />
215+
</wsdl:operation>
216+
<wsdl:operation name="queryView">
217+
<wsdl:input message="tns:queryView" name="queryView" />
218+
<wsdl:output message="tns:queryViewResponse" name="queryViewResponse" />
219+
</wsdl:operation>
220+
<wsdl:operation name="reportLog">
221+
<wsdl:input message="tns:reportLog" name="reportLog" />
222+
<wsdl:output message="tns:reportLogResponse" name="reportLogResponse" />
223+
</wsdl:operation>
224+
</wsdl:portType>
225+
<wsdl:binding name="WSSmCommUpperImplServiceSoapBinding" type="tns:http:wssmcommupper">
226+
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
227+
<wsdl:operation name="reportHealthView">
228+
<soap:operation soapAction="" style="document" />
229+
<wsdl:input name="reportHealthView">
230+
<soap:body use="literal" />
231+
</wsdl:input>
232+
<wsdl:output name="reportHealthViewResponse">
233+
<soap:body use="literal" />
234+
</wsdl:output>
235+
</wsdl:operation>
236+
<wsdl:operation name="reportPolicy">
237+
<soap:operation soapAction="" style="document" />
238+
<wsdl:input name="reportPolicy">
239+
<soap:body use="literal" />
240+
</wsdl:input>
241+
<wsdl:output name="reportPolicyResponse">
242+
<soap:body use="literal" />
243+
</wsdl:output>
244+
</wsdl:operation>
245+
<wsdl:operation name="queryPolicy">
246+
<soap:operation soapAction="" style="document" />
247+
<wsdl:input name="queryPolicy">
248+
<soap:body use="literal" />
249+
</wsdl:input>
250+
<wsdl:output name="queryPolicyResponse">
251+
<soap:body use="literal" />
252+
</wsdl:output>
253+
</wsdl:operation>
254+
<wsdl:operation name="reportConfig">
255+
<soap:operation soapAction="" style="document" />
256+
<wsdl:input name="reportConfig">
257+
<soap:body use="literal" />
258+
</wsdl:input>
259+
<wsdl:output name="reportConfigResponse">
260+
<soap:body use="literal" />
261+
</wsdl:output>
262+
</wsdl:operation>
263+
<wsdl:operation name="reportEvent">
264+
<soap:operation soapAction="" style="document" />
265+
<wsdl:input name="reportEvent">
266+
<soap:body use="literal" />
267+
</wsdl:input>
268+
<wsdl:output name="reportEventResponse">
269+
<soap:body use="literal" />
270+
</wsdl:output>
271+
</wsdl:operation>
272+
<wsdl:operation name="reportView">
273+
<soap:operation soapAction="" style="document" />
274+
<wsdl:input name="reportView">
275+
<soap:body use="literal" />
276+
</wsdl:input>
277+
<wsdl:output name="reportViewResponse">
278+
<soap:body use="literal" />
279+
</wsdl:output>
280+
</wsdl:operation>
281+
<wsdl:operation name="queryConfig">
282+
<soap:operation soapAction="" style="document" />
283+
<wsdl:input name="queryConfig">
284+
<soap:body use="literal" />
285+
</wsdl:input>
286+
<wsdl:output name="queryConfigResponse">
287+
<soap:body use="literal" />
288+
</wsdl:output>
289+
</wsdl:operation>
290+
<wsdl:operation name="queryView">
291+
<soap:operation soapAction="" style="document" />
292+
<wsdl:input name="queryView">
293+
<soap:body use="literal" />
294+
</wsdl:input>
295+
<wsdl:output name="queryViewResponse">
296+
<soap:body use="literal" />
297+
</wsdl:output>
298+
</wsdl:operation>
299+
<wsdl:operation name="reportLog">
300+
<soap:operation soapAction="" style="document" />
301+
<wsdl:input name="reportLog">
302+
<soap:body use="literal" />
303+
</wsdl:input>
304+
<wsdl:output name="reportLogResponse">
305+
<soap:body use="literal" />
306+
</wsdl:output>
307+
</wsdl:operation>
308+
</wsdl:binding>
309+
<wsdl:service name="WSSmCommUpperImplService">
310+
<wsdl:port binding="tns:WSSmCommUpperImplServiceSoapBinding" name="WSSmCommUpperImplPort">
311+
<soap:address location="http://172.20.22.9:10081/WSSmCommUpper/WSSmCommUpper" />
312+
</wsdl:port>
313+
</wsdl:service>
314+
</wsdl:definitions>

0 commit comments

Comments
 (0)