Skip to content

Fix bug #47925: PHPClient can't decompress response (transposed uncompress methods?) #14321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

The incorrect functions are being called to deal with incoming compressed data.
gzip/x-gzip corresponds to gzuncompress(), while deflate corresponds to gzinflate().

The existing code for gzip compression also plays with removing the first 10 bytes (i.e. the gzip header) to pass it to the inflate implementation but that doesn't always work properly due to trailer data. Get rid of that entirely by using the correct functions.

…press methods?)

The incorrect functions are being called to deal with incoming
compressed data.
gzip/x-gzip corresponds to gzuncompress(), while deflate corresponds to
gzinflate().

The existing code for gzip compression also plays with removing the
first 10 bytes (i.e. the gzip header) to pass it to the inflate
implementation but that doesn't always work properly due to trailer
data. Get rid of that entirely by using the correct functions.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes sense in the zlib extension to expose those as C functions to prevent a VM re-entry

@nielsdos
Copy link
Member Author

I wonder if it makes sense in the zlib extension to expose those as C functions to prevent a VM re-entry

Probably, not sure if we always use lazy function linking when loading a dso though, I guess we do by default.

@nielsdos nielsdos closed this in 35e62e9 May 27, 2024
@TimWolla
Copy link
Member

This PR regressed the following test case:

<?php
$client = new SOAPClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", array(
	"features" => SOAP_SINGLE_ELEMENT_ARRAYS,
	"compression" => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
	"exceptions" => true,
	"encoding" => "UTF-8",
));
$response = $client->checkVat(array('countryCode' => 'DE', 'vatNumber' => '811569869'));
var_dump($response);

Before:

object(stdClass)#4 (6) {
  ["countryCode"]=>
  string(2) "DE"
  ["vatNumber"]=>
  string(9) "811569869"
  ["requestDate"]=>
  string(16) "2024-05-28+02:00"
  ["valid"]=>
  bool(true)
  ["name"]=>
  string(3) "---"
  ["address"]=>
  string(3) "---"
}

After:

Warning: gzuncompress(): data error in php-src/test.php on line 8

Fatal error: Uncaught SoapFault exception: [HTTP] Can't uncompress compressed response in php-src/test.php:8
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://ec.europ...', '', 1, false)
#1 php-src/test.php(8): SoapClient->__call('checkVat', Array)
#2 {main}
  thrown in php-src/test.php on line 8

@nielsdos
Copy link
Member Author

Fix here: #14348 Thanks for notifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants