Skip to content

Commit 8896bd3

Browse files
committed
Merge branch 'PHP-8.3'
* PHP-8.3: Fix bug #47925: PHPClient can't decompress response (transposed uncompress methods?)
2 parents a70fd53 + deeeacf commit 8896bd3

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

ext/soap/php_http.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,13 +1279,13 @@ int make_http_soap_request(zval *this_ptr,
12791279

12801280
if ((strcmp(content_encoding,"gzip") == 0 ||
12811281
strcmp(content_encoding,"x-gzip") == 0) &&
1282-
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1283-
ZVAL_STRING(&func, "gzinflate");
1284-
ZVAL_STRINGL(&params[0], http_body->val+10, http_body->len-10);
1285-
} else if (strcmp(content_encoding,"deflate") == 0 &&
1286-
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1282+
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
12871283
ZVAL_STRING(&func, "gzuncompress");
12881284
ZVAL_STR_COPY(&params[0], http_body);
1285+
} else if (strcmp(content_encoding,"deflate") == 0 &&
1286+
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1287+
ZVAL_STRING(&func, "gzinflate");
1288+
ZVAL_STR_COPY(&params[0], http_body);
12891289
} else {
12901290
efree(content_encoding);
12911291
zend_string_release_ex(http_headers, 0);

ext/soap/tests/bugs/bug47925.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug #47925 (PHPClient can't decompress response (transposed uncompress methods?))
3+
--EXTENSIONS--
4+
soap
5+
zlib
6+
--SKIPIF--
7+
<?php
8+
if (@!include __DIR__."/../../../standard/tests/http/server.inc") die('skip server.inc not available');
9+
http_server_skipif();
10+
?>
11+
--FILE--
12+
<?php
13+
require __DIR__."/../../../standard/tests/http/server.inc";
14+
15+
$plain_response = <<<XML
16+
<?xml version="1.0" encoding="UTF-8"?>
17+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
18+
<SOAP-ENV:Body>
19+
<ns1:AddResponse>
20+
<return xsi:type="xsd:int">7</return>
21+
</ns1:AddResponse>
22+
</SOAP-ENV:Body>
23+
</SOAP-ENV:Envelope>
24+
XML;
25+
26+
function test($compressed_response, $compression_name) {
27+
$length = strlen($compressed_response);
28+
$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");
29+
['pid' => $pid, 'uri' => $uri] = http_server([$server_response]);
30+
$client = new SoapClient(NULL, ['location' => $uri, 'uri' => $uri]);
31+
var_dump($client->Add(3, 4));
32+
http_server_kill($pid);
33+
}
34+
35+
test(gzcompress($plain_response), "gzip");
36+
test(gzdeflate($plain_response), "deflate");
37+
?>
38+
--EXPECT--
39+
int(7)
40+
int(7)

0 commit comments

Comments
 (0)