diff --git a/NEWS b/NEWS index 107d88aa32b..d52836f2709 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,9 @@ PHP NEWS . Fixed bug GH-14267 (opcache.jit=off does not allow enabling JIT at runtime). (ilutov) +- Soap: + . Fixed bug #47925 (PHPClient can't decompress response). (nielsdos) + - Sodium: . Fix memory leaks in ext/sodium on failure of some functions. (nielsdos) diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 5a887bd1e1e..f60f8b21caa 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -1258,13 +1258,13 @@ try_again: if ((strcmp(content_encoding,"gzip") == 0 || strcmp(content_encoding,"x-gzip") == 0) && - zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) { - ZVAL_STRING(&func, "gzinflate"); - ZVAL_STRINGL(¶ms[0], http_body->val+10, http_body->len-10); - } else if (strcmp(content_encoding,"deflate") == 0 && - zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) { + zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) { ZVAL_STRING(&func, "gzuncompress"); ZVAL_STR_COPY(¶ms[0], http_body); + } else if (strcmp(content_encoding,"deflate") == 0 && + zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) { + ZVAL_STRING(&func, "gzinflate"); + ZVAL_STR_COPY(¶ms[0], http_body); } else { efree(content_encoding); zend_string_release_ex(http_headers, 0); diff --git a/ext/soap/tests/bugs/bug47925.phpt b/ext/soap/tests/bugs/bug47925.phpt new file mode 100644 index 00000000000..ce14c7f4676 --- /dev/null +++ b/ext/soap/tests/bugs/bug47925.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #47925 (PHPClient can't decompress response (transposed uncompress methods?)) +--EXTENSIONS-- +soap +zlib +--SKIPIF-- + +--FILE-- + + + + + 7 + + + +XML; + +function test($compressed_response, $compression_name) { + $length = strlen($compressed_response); + $server_response = "data://text/xml;base64," . base64_encode("HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Encoding: $compression_name\r\nContent-Length: $length\r\n\r\n$compressed_response"); + ['pid' => $pid, 'uri' => $uri] = http_server([$server_response]); + $client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]); + var_dump($client->Add(3, 4)); + http_server_kill($pid); +} + +test(gzcompress($plain_response), "gzip"); +test(gzdeflate($plain_response), "deflate"); +?> +--EXPECT-- +int(7) +int(7)