[issue27164] zlib can't decompress DEFLATE using shared dictionary

Xiang Zhang report at bugs.python.org
Thu Jun 2 01:59:08 EDT 2016


Xiang Zhang added the comment:

Thanks for your review, Martin. :) I have replied with after thinking and try.

Yes, this is more like a feature request. But for the end user, this behaviour is quite like a bug.

> If we were to add full support of inflateSetDictionary() for raw deflate mode, I imagine it would be a new decompressobj.set_dictionary() method.

I don't support adding a new set_dictionary() method. Right now decompressobj handles raw deflate format, zlib format and gzip format. Adding a set_dictionary() method for raw deflate format seems weird. If we are going to do so, I suggest reorganize the zlib like PHP and nodejs do, separating different formats into different objects.

> I did some quick tests with specifying an unnecessary zdict buffer to the decompressor (when zdict not used for compression), and it doesn’t _seem_ to break anything, but I am not 100% sure.

This patch only affects raw inflate. You have to set wbits negative. If you are decompressing with an unnecessary zdict, I think it ought to emit an error.

With Python background, zlib dictionary is really hard to understand. I think manual doesn't tell much. I understand why zdict is needed until reading https://blog.cloudflare.com/improving-compression-with-preset-deflate-dictionary/.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27164>
_______________________________________


More information about the Python-bugs-list mailing list