-
-
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
fix: Use a null prototype object for this.files #766
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,19 @@ QUnit.module("load", function () { | |
})['catch'](JSZipTestUtils.assertNoError); | ||
}); | ||
|
||
JSZipTestUtils.testZipFile("Load files which shadow Object prototype methods", "ref/pollution.zip", function(assert, file) { | ||
var done = assert.async(); | ||
assert.ok(typeof file === "string"); | ||
JSZip.loadAsync(file) | ||
.then(function (zip) { | ||
assert.notEqual(Object.getPrototypeOf(zip.files), zip.files.__proto__); | ||
return zip.file("__proto__").async("string"); }) | ||
.then(function(result) { | ||
assert.equal(result, "hello\n", "the zip was correctly read."); | ||
done(); | ||
})['catch'](JSZipTestUtils.assertNoError); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point - but I'm not entirely sure how to test this change because essentially this change is about making sure I guess I could add a test that shows that The reasoning for this test specifically was to show that files with names that shadow standard Object method names can still be accessed correctly |
||
|
||
JSZipTestUtils.testZipFile("load(string) handles bytes > 255", "ref/all.zip", function(assert, file) { | ||
var done = assert.async(); | ||
// the method used to load zip with ajax will remove the extra bits. | ||
|
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.
@Stuk we could use
for(filename of Object.keys(this.files)) {
here instead, but it seemsjszip
is targetting es3 injshintrc
.We could set this to
es6
but I assume this would break for a number of users and you would want to avoid that?This is the error that comes up if I change it:
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.
Yeah, there's a bigger task for upgrading the tooling and browser compatibility for this library. The approach here looks good.