-
Notifications
You must be signed in to change notification settings - Fork 535
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
gzuncompress(): data error #659
Comments
We need a little bit more information. What PHP version do you run? I assume you tried 2.8.0-RC2? Can you provide the PDF which causes this behavior? If not, try to debug to the point where the error is triggered and give us the parameters of the functions so we can reproduce the error locally. And last, why did you reference #622? |
PHP version is 7.4.2
This error appears in Smalot/PdfParser/RawData/FilterHelper. php: 241
Function is:
/**
* FlateDecode
*
* Decompresses data encoded using the zlib/deflate compression method, reproducing the original text or binary data.
*
* @param string $data Data to decode
* @param int $decodeMemoryLimit Memory limit on deflation
*
* @return string data string
*
* @throws \Exception
*/
protected function decodeFilterFlateDecode(string $data, int $decodeMemoryLimit): ?string
{
// Uncatchable E_WARNING for "data error" is @ suppressed
// so execution may proceed with an alternate decompression
// method.
$decoded = @gzuncompress($data, $decodeMemoryLimit);
if (false === $decoded) {
// If gzuncompress() failed, try again using the compress.zlib://
// wrapper to decode it in a file-based context.
// See: https://www.php.net/manual/en/function.gzuncompress.php#79042
// Issue: #592
$ztmp = tmpfile();
if (false != $ztmp) {
fwrite($ztmp, "\x1f\x8b\x08\x00\x00\x00\x00\x00".$data);
$file = stream_get_meta_data($ztmp)['uri'];
if (0 === $decodeMemoryLimit) {
$decoded = file_get_contents('compress.zlib://'.$file);
} else {
$decoded = file_get_contents('compress.zlib://'.$file, false, null, 0, $decodeMemoryLimit);
}
fclose($ztmp);
}
}
if (false === \is_string($decoded) || '' === $decoded) {
// If the decoded string is empty, that means decoding failed.
throw new \Exception('decodeFilterFlateDecode: invalid data');
}
return $decoded;
}
params is
$data = "�s��8�S4z�2A�ٮ��������n�O���)q,�ӕ�ik�7l�B:��<Lgz?��C�/�UL�"XZ�@���ui~-�����٥~�&K��"&8_�E����A�f
***@***.***�Kj��s����!3�Q�<�������#
ŀ>�����3�|�L"
$decodeMemoryLimit = 1000000
At 2023-12-20 16:07:38, "Konrad Abicht" ***@***.***> wrote:
We need a little bit more information. What PHP version do you run? I assume you tried 2.8.0-RC?
Can you provide the PDF which causes this behavior? If not, try to debug to the point where the error is triggered and give us the parameters of the functions so we can reproduce the error locally.
And last, why did you reference #622?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
HI, k00ni Is there a way to solve this problem, I hope to receive your help! |
Can you help me solve my problem? |
Sorry for the late response, I hope I can get back to you the next week. |
Hi k00ni If you need to reproduce this error, you can do it like this, $decoded in the code will return false. Please run this code to reproduce the issue /**
|
Might this have something to do with your PHP version? You're using 7.4.2. I'm using 8.3.0 and can't reproduce your error with the code you've given. No errors appear in my PHP error log. |
If it is a problem with the PHP version, can you fix this issue with compatibility? I hope this error will not be reported in version 7.4.2 |
Can we assume you have to use PHP 7.4.2? |
I encountered a problem while using it.
Attempting to update to the latest version, the issue still exists.
How should I block this exception.
#622
The text was updated successfully, but these errors were encountered: