Function.gzinflate Data Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business gzinflate(): data error wordpress Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs gzinflate data error php Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just gzinflate online like you, helping each other. Join them; it only takes a minute: Sign up PHP Warning: gzinflate(): data error in up vote 0 down vote favorite I pack my code using gzdeflate(), after I do addslashes() and gzinflate php write it to file like $var ='MY_RESULT'; After it I try to execute it using eval(stripslashes(gzinflate($var))) and get error Warning: gzinflate(): data error in this row. If I set $var = addslashes(gzdeflate("my_original_code")) everything work nice, but I need to put deflated result in this variable. So where is my mistake? Here is my code:
Php Warning Gzinflate()
'wb'); fwrite($fp, $result); fclose($fp); php gz share|improve this question edited Oct 11 '14 at 19:25 asked Oct 11 '14 at 16:00 ShabbyTon 112 Apart from the missing semi-colon at the end of line 5 ($b = "...;";), a simplified version of that code with no write to file appears to work fine: 3v4l.org/Uigv4 –IMSoP Oct 11 '14 at 19:06 Yes, but I need working code with writing to file. –ShabbyTon Oct 11 '14 at 19:28 1 My point was that I could not reproduce your problem with the simplified example, and that that might help narrow down the problem. I'm trying to help you discover the problem, not write your code for you. –IMSoP Oct 11 '14 at 19:33 In fact, putting the file-writing back in still results in working code for me. Here is the code I ran: gist.github.com/IMSoP/368a6819b07458912b8a –IMSoP Oct 11 '14 at 19:39 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote You need to reverse the order of encoding steps when you're decoding. Encoding steps: take the code, apply gzip compression, giving compressed code take the compressed code, add slashes, giving escaped compressed code Your current decoding steps: take the escaped compressed code, and attempt to decompress it take the result of (1) and attempt t
a New Ticket Search: LoginNotifications Context Navigation ← Previous TicketNext Ticket → Opened 4 years ago Closed 12 days ago #22952 closed defect (bug) (duplicate) WP_HTTP can cause PHP Warnings during attempted decompression Reported by: dd32 Owned by: Milestone: Priority: normal Severity: normal
Warning: Wp-includes/class-wp-http-encoding.php:58 - Gzinflate(): Data Error
Version: 3.3 Component: HTTP API Keywords: has-patch needs-testing Focuses: Cc: Description (last modified by SergeyBiryukov) gzinflate base64_decode hack WARNING: wp-includes/class-http.php:1656 - gzinflate(): data error WP_Http_Encoding can cause PHP Warnings when it attempts to decompress data using gzinflate() which has been str_rot13 encoded in any way. We currently work around this this in a few ways, but we still take a "try it and see" method instead of detecting the compressed contents signature and handling it appropriately. Attached http://stackoverflow.com/questions/26316521/php-warning-gzinflate-data-error-in is a first-run patch at detecting Huffman coding, which is what we currently use @gzinflate( substr( $gzData, 2 ) ) for (and hey, who doesn't like making magic numbers clearer?) I have been running a similar patch on WordPress.com and gathering data on how the myriad of different Web Servers out there respond, and so far this causes it to correctly identify the vast majority of responses. It appears that we may https://core.trac.wordpress.org/ticket/22952 also be attempting to decompress compressed files retrieved through WP_HTTP on some poorly configured servers, but this is something I haven't yet traced properly. Attachments (3) 22952.diff (2.2 KB) - added by dd32 4 years ago. 22952.2.diff (2.2 KB) - added by dd32 4 years ago. 22952.3.diff (4.6 KB) - added by dd32 2 years ago. Download all attachments as: .zip Oldest first Newest first Threaded Comments only Change History (41) @dd32 4 years ago Attachment 22952.diff added #1 @SergeyBiryukov 4 years ago Description modified (diff) #2 @dd32 4 years ago I have also considered that we're using gzinflate() completely wrong, for example: gzencode() == gzip gzcompress() == zlib (aka. HTTP deflate) gzdeflate() == *raw* deflate encoding Currently we use gzinflate() (the raw DEFLATE standard) to decompress the data created by compressors which add their compression header/footer wrappers. gzuncompress() for example handles Huffman encoding internally, as it's designed for uncompressing HTTP "deflated" content. gzdecode() on the other hand is designed for gzip encoded files (which uses DEFLATE internally as the compression method) which has it's own headers (as it's designed for multiple files stored within the archive) - I believe this is the appropriate function to decompress data for the block above the changes in WP_Http_Encoding::compatible_gzinflate() which strips the full zlib headers Ultimately, we've been bitten
Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols and Wrappers Security Introduction General considerations Installed as CGI binary Installed as an Apache module http://php.net/manual/en/function.gzinflate.php Session Security Filesystem Security Database Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line data error Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions gzinflate(): data error Web Services Windows Only Extensions XML Manipulation Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box gzopen » « gzgetss PHP Manual Function Reference Compression and Archive Extensions Zlib Zlib Functions Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug gzinflate (PHP 4 >= 4.0.4, PHP 5, PHP 7)gzinflate — Inflate a deflated string Description string gzinflate ( string $data [, int $length = 0 ] ) This function inflates a deflated string. Parameters data The data compressed by gzdeflate(). length The maximum length of data to decode. Return Values The original uncompressed data or FALSE on error. The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input data or more than the optional parameter length. Examples Example #1 gzinflate() example $compressed=