Skip to content

Commit dd227f6

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #69668: SOAP special XML characters in namespace URIs not encoded Signed-off-by: Christoph M. Becker <cmbecker69@gmx.de>
2 parents d7ae646 + 75cb678 commit dd227f6

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ PHP NEWS
2929
. Fixed bug #80889 (Cannot set save handler when save_handler is invalid).
3030
(cmb)
3131

32+
- SOAP:
33+
. Fixed bug #69668 (SOAP special XML characters in namespace URIs not
34+
encoded). (cmb)
35+
3236
01 Apr 2021, PHP 8.0.4
3337

3438
- Core:

ext/soap/php_encoding.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3379,6 +3379,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
33793379
} else {
33803380
smart_str prefix = {0};
33813381
int num = ++SOAP_GLOBAL(cur_uniq_ns);
3382+
xmlChar *enc_ns;
33823383

33833384
while (1) {
33843385
smart_str_appendl(&prefix, "ns", 2);
@@ -3392,7 +3393,9 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
33923393
num = ++SOAP_GLOBAL(cur_uniq_ns);
33933394
}
33943395

3395-
xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.s ? ZSTR_VAL(prefix.s) : ""));
3396+
enc_ns = xmlEncodeSpecialChars(node->doc, BAD_CAST(ns));
3397+
xmlns = xmlNewNs(node->doc->children, enc_ns, BAD_CAST(prefix.s ? ZSTR_VAL(prefix.s) : ""));
3398+
xmlFree(enc_ns);
33963399
smart_str_free(&prefix);
33973400
}
33983401
}

ext/soap/tests/bug69668.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #69668 (SOAP: special XML characters in namespace URIs not encoded)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
?>
7+
--FILE--
8+
<?php
9+
class MySoapClient extends SoapClient {
10+
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
11+
echo $request, PHP_EOL;
12+
return '';
13+
}
14+
}
15+
16+
$client = new MySoapClient(__DIR__ . '/bug69668.wsdl', [
17+
'trace' => true,
18+
'exceptions' => true,
19+
'cache_wsdl' => WSDL_CACHE_NONE,
20+
]);
21+
22+
$client->test();
23+
?>
24+
--EXPECT--
25+
<?xml version="1.0" encoding="UTF-8"?>
26+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/69668.php?a=a&amp;b=b" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test/></SOAP-ENV:Body></SOAP-ENV:Envelope>

ext/soap/tests/bug69668.wsdl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/69668.php?a=a&amp;b=b" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
3+
xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="TestService" targetNamespace="http://localhost/69668.php?a=a&amp;b=b">
4+
<types>
5+
<xsd:schema targetNamespace="http://localhost/69668.php?a=a&amp;b=b" />
6+
</types>
7+
<portType name="TestServicePort">
8+
<operation name="test">
9+
<documentation>test</documentation>
10+
<input message="tns:testIn" />
11+
<output message="tns:testOut" />
12+
</operation>
13+
</portType>
14+
<binding name="TestServiceBinding" type="tns:TestServicePort">
15+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
16+
<operation name="test">
17+
<soap:operation soapAction="http://localhost/69668.php?a=a&amp;b=b#test" />
18+
<input>
19+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/69668.php?a=a&amp;b=b" />
20+
</input>
21+
<output>
22+
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/69668.php?a=a&amp;b=b" />
23+
</output>
24+
</operation>
25+
</binding>
26+
<service name="TestServiceService">
27+
<port name="TestServicePort" binding="tns:TestServiceBinding">
28+
<soap:address location="http://localhost/69668.php?a=a&amp;b=b" />
29+
</port>
30+
</service>
31+
<message name="testIn" />
32+
<message name="testOut">
33+
<part name="return" type="xsd:string" />
34+
</message>
35+
</definitions>

0 commit comments

Comments
 (0)