From 9a1ccb6605e82e76f0034fe66fdd0497eeb3f2c0 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. --- ext/soap/php_sdl.c | 2 +- ext/soap/tests/gh8538.phpt | 30 ++++ ext/soap/tests/gh8538.wsdl | 314 +++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 ext/soap/tests/gh8538.phpt create mode 100644 ext/soap/tests/gh8538.wsdl diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index a271ca8fcd23..e5e7f2f95540 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 000000000000..18386f5d4b74 --- /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 000000000000..cbcb4b9aa13b --- /dev/null +++ b/ext/soap/tests/gh8538.wsdl @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file