Skip to content

Commit deeeacf

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix bug #47925: PHPClient can't decompress response (transposed uncompress methods?)
2 parents b09922b + 35e62e9 commit deeeacf

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ PHP NEWS
1212
. Fixed bug GH-14267 (opcache.jit=off does not allow enabling JIT at runtime).
1313
(ilutov)
1414

15+
- Soap:
16+
. Fixed bug #47925 (PHPClient can't decompress response). (nielsdos)
17+
1518
- Sodium:
1619
. Fix memory leaks in ext/sodium on failure of some functions. (nielsdos)
1720

ext/soap/php_http.c

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

12591259
if ((strcmp(content_encoding,"gzip") == 0 ||
12601260
strcmp(content_encoding,"x-gzip") == 0) &&
1261-
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1262-
ZVAL_STRING(&func, "gzinflate");
1263-
ZVAL_STRINGL(&params[0], http_body->val+10, http_body->len-10);
1264-
} else if (strcmp(content_encoding,"deflate") == 0 &&
1265-
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
1261+
zend_hash_str_exists(EG(function_table), "gzuncompress", sizeof("gzuncompress")-1)) {
12661262
ZVAL_STRING(&func, "gzuncompress");
12671263
ZVAL_STR_COPY(&params[0], http_body);
1264+
} else if (strcmp(content_encoding,"deflate") == 0 &&
1265+
zend_hash_str_exists(EG(function_table), "gzinflate", sizeof("gzinflate")-1)) {
1266+
ZVAL_STRING(&func, "gzinflate");
1267+
ZVAL_STR_COPY(&params[0], http_body);
12681268
} else {
12691269
efree(content_encoding);
12701270
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)