classification
Title: raw deflate format and zlib module
Type: enhancement Stage:
Components: Documentation Versions: Python 3.3, Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, nadeem.vawda, phr, terry.reedy
Priority: normal Keywords:

Created on 2009-04-17 22:10 by phr, last changed 2012-01-26 13:05 by nadeem.vawda.

Messages (3)
msg86094 - (view) Author: paul rubin (phr) Date: 2009-04-17 22:10
The zlib module doesn't support raw deflate format, so it doesn't
completely interoperate with php's "gzdeflate" function and fails to
decompress some strings that web browsers can decompress.

A workaround is to use a special zlib feature and pass the value -15 as
the "wbits" arg: 

plaintext = zlib.deflate(compressed_text, wbits=-15)

I don't know if it's appropriate to mess with the code, but at minimum I
urge that the workaround be mentioned in the docs.  We had a tremendous
distruption where I work because of a malicious raw-deflated PHP script
that we couldn't decompress with Python for analysis.  We had to resort
to decompressing in a PHP container that (through my slipping up) it
proceeded to escape from.  

Help us Python-Kenobi, save us from PHP ;-)
msg86095 - (view) Author: paul rubin (phr) Date: 2009-04-17 22:28
I should have mentioned, the docs do say "When wbits is negative, the
standard gzip header is suppressed; this is an undocumented feature of
the zlib library, used for compatibility with unzip‘s compression file
format" but this wasn't enough at the time to figure out the issue.  I
suggest adding something like "and the 'raw deflate' format supported by
PHP and some web browsers.  

I better see if I can research the exact situation a bit further, for
the sake of documenting it accurately, if others here think it's a good
idea.
msg109661 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-09 01:36
A doc addition would seem like a good idea, so I am changing this to a doc issue for the current versions. Can you suggest specific text and a specific location to place it?

A behavior change could only go into 3.2. I do not know who, if anyone, maintains zlib. A reference to the desired algorithm might be necessary.
History
Date User Action Args
2012-01-26 13:05:18nadeem.vawdasetnosy: + nadeem.vawda
2011-03-09 02:26:09terry.reedysetnosy: terry.reedy, phr, docs@python
versions: + Python 3.3
2010-08-07 18:31:32terry.reedysetversions: - Python 2.6
2010-07-09 01:36:54terry.reedysetversions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, - Python 2.5
nosy: + terry.reedy, docs@python

messages: + msg109661

assignee: docs@python
components: + Documentation, - Library (Lib)
2009-04-17 22:28:59phrsetmessages: + msg86095
2009-04-17 22:10:48phrsettype: enhancement
components: + Library (Lib)
versions: + Python 2.5
2009-04-17 22:10:20phrcreate