summaryrefslogtreecommitdiff
path: root/ext/soap/php_http.c
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2020-08-18 18:10:39 +0200
committerMatteo Beccati <mbeccati@php.net>2020-08-18 18:10:39 +0200
commitf7c43b8c72822a4722bd7404c6f65e15b2b912c1 (patch)
treef32aef057af1f6ea87176c6528bafe516d0a1e7b /ext/soap/php_http.c
parentff14b7adad4c63cc9f7118fd1794e006593391f8 (diff)
downloadphp-git-f7c43b8c72822a4722bd7404c6f65e15b2b912c1.tar.gz
Fix #47021: SoapClient stumbles over WSDL delivered with "Transfer-Encoding: chunked"
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r--ext/soap/php_http.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index fb3089ec27..b054d9ba9e 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -1375,11 +1375,24 @@ static char *get_http_header_value(char *headers, char *type)
/* match */
tmp = pos + typelen;
+
+ /* strip leading whitespace */
+ while (*tmp == ' ' || *tmp == '\t') {
+ tmp++;
+ }
+
eol = strchr(tmp, '\n');
if (eol == NULL) {
eol = headers + headerslen;
- } else if (eol > tmp && *(eol-1) == '\r') {
- eol--;
+ } else if (eol > tmp) {
+ if (*(eol-1) == '\r') {
+ eol--;
+ }
+
+ /* strip trailing whitespace */
+ while (eol > tmp && (*(eol-1) == ' ' || *(eol-1) == '\t')) {
+ eol--;
+ }
}
return estrndup(tmp, eol - tmp);
}