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

Compression level 3 has bugs? #22

Closed
SikaGrr opened this issue Dec 10, 2012 · 4 comments
Closed

Compression level 3 has bugs? #22

SikaGrr opened this issue Dec 10, 2012 · 4 comments

Comments

@SikaGrr
Copy link

SikaGrr commented Dec 10, 2012

Inflating a string that was deflated using lvl3 compression will duplicate the last character. It will also, once in a blue moon, produce an output that can't be inflated (it crashes the .net deflatestream).

@dduponchel
Copy link
Collaborator

Do you have any example ? I tried to reproduce it with zip -3 without luck.

@leok7v
Copy link

leok7v commented Dec 22, 2012

try data with chars > 0x255

@dduponchel
Copy link
Collaborator

Found the bug. When changing the zip_DEFAULT_LEVEL (in jszip-deflate.js) from 6 to a value <= 3, the following test case fails.

test("DEFLATE should not change the content", function(){
   var string = "test";
   var zip = new JSZip();
   zip.file("test.txt", string);
   var reloadedZip = new JSZip(zip.generate({base64:false,compression:'DEFLATE'}));

   equals(reloadedZip.file("test.txt").data, string);
}); 

In the file jszip-deflate.js, there are two if(zip_compr_level <= 3) // optimized for speed. When removed, this test case works but I don't know if this breaks other cases.

The work-around is to keep the zip_DEFAULT_LEVEL above 3.

@Stuk
Copy link
Owner

Stuk commented Oct 5, 2013

Fixed in #56

@Stuk Stuk closed this as completed Oct 5, 2013
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

4 participants