-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from 10bitFX/info-zip-password
Add support for Info-Zip password check spec for ZipCrypto.
- Loading branch information
Showing
5 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
// Tests for github issue 471: https://github.com/cthackers/adm-zip/issues/471 | ||
|
||
const assert = require("assert"); | ||
const path = require("path"); | ||
const Zip = require("../../adm-zip"); | ||
|
||
describe("decryption with info-zip spec password check", () => { | ||
|
||
|
||
// test decryption with both password types | ||
it("test decrypted data with password", () => { | ||
// the issue-471-infozip-encrypted.zip file has been generated with Info-Zip Zip 2.32, but the Info-Zip | ||
// standard is used by other zip generators as well. | ||
const infoZip = new Zip(path.join(__dirname, "../assets/issue-471-infozip-encrypted.zip")); | ||
const entries = infoZip.getEntries(); | ||
assert(entries.length === 1, "Good: Test archive contains exactly 1 file"); | ||
|
||
const testFile = entries.filter(function (entry) { | ||
return entry.entryName === "dummy.txt"; | ||
}); | ||
assert(testFile.length === 1, "Good: dummy.txt file exists as archive entry"); | ||
|
||
const readData = entries[0].getData('secret'); | ||
assert(readData.toString('utf8').startsWith('How much wood could a woodchuck chuck'), "Good: buffer matches expectations"); | ||
|
||
// assert that the following call throws an exception | ||
assert.throws(() => { | ||
const readDataBad = entries[0].getData('badpassword'); | ||
}, "Good: error thrown for bad password"); | ||
|
||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters