From 2a13304b2e85a9db351582b3f950b01f38c7c7dc Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Thu, 12 May 2022 15:23:12 +0200 Subject: [PATCH] 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. --- NEWS | 1 + ext/soap/php_sdl.c | 2 +- ext/soap/tests/gh8538.phpt | 30 ++++ ext/soap/tests/gh8538.wsdl | 314 +++++++++++++++++++++++++++++++++++++ 4 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 ext/soap/tests/gh8538.phpt create mode 100644 ext/soap/tests/gh8538.wsdl diff --git a/NEWS b/NEWS index e39b10d1a65..92795c90345 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,7 @@ PHP NEWS - Soap: . Fixed bug GH-8578 (Error on wrong parameter on SoapHeader constructor). (robertnisipeanu) + . Fixed bug GH-8538 (SoapClient may strip parts of nmtokens). (cmb) - SPL: . Fixed bug GH-8235 (iterator_count() may run indefinitely). (cmb) diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index a271ca8fcd2..e5e7f2f9554 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -883,7 +883,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri) soap_error0(E_ERROR, "Parsing WSDL: Missing 'type' attribute for "); } - ctype = strrchr((char*)type->children->content,':'); + ctype = strchr((char*)type->children->content,':'); if (ctype == NULL) { ctype = (char*)type->children->content; } else { diff --git a/ext/soap/tests/gh8538.phpt b/ext/soap/tests/gh8538.phpt new file mode 100644 index 00000000000..18386f5d4b7 --- /dev/null +++ b/ext/soap/tests/gh8538.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug GH-8538 (SoapClient may strip parts of nmtokens) +--SKIPIF-- + +--FILE-- +__getFunctions()); +?> +--EXPECT-- +array(9) { + [0]=> + string(71) "reportHealthViewResponse reportHealthView(reportHealthView $parameters)" + [1]=> + string(59) "reportPolicyResponse reportPolicy(reportPolicy $parameters)" + [2]=> + string(56) "queryPolicyResponse queryPolicy(queryPolicy $parameters)" + [3]=> + string(59) "reportConfigResponse reportConfig(reportConfig $parameters)" + [4]=> + string(56) "reportEventResponse reportEvent(reportEvent $parameters)" + [5]=> + string(53) "reportViewResponse reportView(reportView $parameters)" + [6]=> + string(56) "queryConfigResponse queryConfig(queryConfig $parameters)" + [7]=> + string(50) "queryViewResponse queryView(queryView $parameters)" + [8]=> + string(50) "reportLogResponse reportLog(reportLog $parameters)" +} diff --git a/ext/soap/tests/gh8538.wsdl b/ext/soap/tests/gh8538.wsdl new file mode 100644 index 00000000000..cbcb4b9aa13 --- /dev/null +++ b/ext/soap/tests/gh8538.wsdl @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file