diff --git a/NEWS b/NEWS
index 01f8af8ac8e..afb437984b3 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,10 @@ PHP NEWS
. Fixed bug #80889 (Cannot set save handler when save_handler is invalid).
(cmb)
+- SOAP:
+ . Fixed bug #69668 (SOAP special XML characters in namespace URIs not
+ encoded). (cmb)
+
01 Apr 2021, PHP 8.0.4
- Core:
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index b3dd853298f..f5723e213a4 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -3379,6 +3379,7 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
} else {
smart_str prefix = {0};
int num = ++SOAP_GLOBAL(cur_uniq_ns);
+ xmlChar *enc_ns;
while (1) {
smart_str_appendl(&prefix, "ns", 2);
@@ -3392,7 +3393,9 @@ xmlNsPtr encode_add_ns(xmlNodePtr node, const char* ns)
num = ++SOAP_GLOBAL(cur_uniq_ns);
}
- xmlns = xmlNewNs(node->doc->children, BAD_CAST(ns), BAD_CAST(prefix.s ? ZSTR_VAL(prefix.s) : ""));
+ enc_ns = xmlEncodeSpecialChars(node->doc, BAD_CAST(ns));
+ xmlns = xmlNewNs(node->doc->children, enc_ns, BAD_CAST(prefix.s ? ZSTR_VAL(prefix.s) : ""));
+ xmlFree(enc_ns);
smart_str_free(&prefix);
}
}
diff --git a/ext/soap/tests/bug69668.phpt b/ext/soap/tests/bug69668.phpt
new file mode 100644
index 00000000000..59b3aa648fc
--- /dev/null
+++ b/ext/soap/tests/bug69668.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #69668 (SOAP: special XML characters in namespace URIs not encoded)
+--SKIPIF--
+
+--FILE--
+ true,
+ 'exceptions' => true,
+ 'cache_wsdl' => WSDL_CACHE_NONE,
+]);
+
+$client->test();
+?>
+--EXPECT--
+
+
diff --git a/ext/soap/tests/bug69668.wsdl b/ext/soap/tests/bug69668.wsdl
new file mode 100644
index 00000000000..675db1e3e4b
--- /dev/null
+++ b/ext/soap/tests/bug69668.wsdl
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+