juvia icon indicating copy to clipboard operation
juvia copied to clipboard

Zlib::DataError: incorrect header check

Open impythonista opened this issue 12 years ago • 3 comments

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'

impythonista avatar Apr 27 '13 07:04 impythonista

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

JangoSteve avatar Apr 27 '13 18:04 JangoSteve

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

impythonista avatar Apr 29 '13 11:04 impythonista

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.

stbuehler avatar Aug 17 '13 10:08 stbuehler