Skip to content
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

Zlib::DataError: incorrect header check #31

Open
impythonista opened this issue Apr 27, 2013 · 3 comments
Open

Zlib::DataError: incorrect header check #31

impythonista opened this issue Apr 27, 2013 · 3 comments

Comments

@impythonista
Copy link

I am facing Zlib::DataError: incorrect header check error for few strings. I got stuck into this issue, so please fix this asap.

I am getting exception only for few compressed string, please find example string in console:

ruby-1.9.3-p125> str = "eMKcK0ktLgEABF0Bw4E="
=> "eMKcK0ktLgEABF0Bw4E="
ruby-1.9.3-p125> Zlib::Inflate.inflate(str.unpack('m').first)
Zlib::DataError: incorrect header check
from (irb):3:in `inflate'

@JangoSteve
Copy link
Collaborator

Could you please be a bit more specific? When and where are you getting this error? What request causes it?

@impythonista
Copy link
Author

When I compress the string using Juvia.compress function and going to decompress it in controller then I face this error.

@stbuehler
Copy link
Contributor

You tried to compress the string "test". The correct result is:

Juvia.compress("test") == "eJwrSS0uAQAEXQHB"

Lets have a look at the base64 decoded values:

>> "eJwrSS0uAQAEXQHB".unpack("m")[0]
=> "x\x9C+I-.\x01\x00\x04]\x01\xC1"
>> "eMKcK0ktLgEABF0Bw4E=".unpack("m")[0]
=> "x\xC2\x9C+I-.\x01\x00\x04]\x01\xC3\x81"

Looks good apart from some strange characters:

>> "eMKcK0ktLgEABF0Bw4E=".unpack("m")[0].unpack("U*").pack("C*")
=> "x\x9C+I-.\x01\x00\x04]\x01\xC1"

So it looks your Base64.encode function interpreted the arguments as utf-8 string, not as "binary" string. My guess is your site includes a different Base64.encode that overwrote the one from juvia.

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

No branches or pull requests

3 participants