-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Handling folder entries for Java programs #33
Conversation
Using the DEFLATE compression on folder entries with empty content cause the Java zip inflator to fail. This fix totally remove content when compressing a folder entry, and set compression to none for this entry.
if (!this.options.binary) { | ||
result = JSZip.prototype.utf8encode(result); | ||
} | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix the indentation here to match the rest of the file (3 spaces)
Indentation fixed ! |
@@ -92,6 +92,9 @@ JSZip.prototype = (function () { | |||
*/ | |||
asBinary : function () { | |||
var result = this.data; | |||
if (result == null) { | |||
return result; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add the same check in the asText method ?
Thanks for the pull request ! |
Check data nullity in asText() to avoid errors
And done ! |
I just found a case where the bug is still here. I think that in the if (o.dir) {
data = null;
} else if (JSZip.support... will cover all the corner cases. What do you think of it ? |
I havn't tested yet (I'll do it on monday), but your fix seems right. |
jszip-load handles empty files : it will just INFLATE an empty string (and get an empty string). But you found an other failing test case : a compressed zip with an empty file.
We should |
Adding the condition If you add a fix for this (I can't add a commit in your pull request), I'll merge this to completely fix the issue. |
This pull request doesn't fix all the cases but doesn't break anything. I'm merging it (without reply from @feugy) and I'll create an other pull request to fix the remaining issues. |
Handling folder entries for Java programs
If the user add an empty file (or a folder), we should STORE the file and not DEFLATE it.
Fix the failing case of the issue #33
Hi David, Stuart. Sorry not to have replied: I was sick for a few days and just after away from an internet connection. Thank you again. |
Glad to see that you're OK ! |
Hello !
We found that Java programs cannot read zip generated by JSZip.
It appears that using the DEFLATE compression on folder entries with empty content cause the Java zip inflator to fail (error 'invalid stored block lengths').
This fix totally remove content when compressing a folder entry, and set compression to none for this entry. All tests passed, without modification on them.
Thank you !
Damien.