From 0c9634efddc6d651d1bfa9245dab83891b19a2d9 Mon Sep 17 00:00:00 2001 From: David Duponchel Date: Sun, 25 Sep 2016 18:25:59 +0200 Subject: [PATCH] Fix crc32 check for empty entries. With entries with no content (folders for example) the crc32 attribute wasn't initialized: `undefined === 0` was false, an error was triggered. --- lib/stream/Crc32Probe.js | 1 + test/asserts/load.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/stream/Crc32Probe.js b/lib/stream/Crc32Probe.js index 3df5aba9..93f0ad38 100644 --- a/lib/stream/Crc32Probe.js +++ b/lib/stream/Crc32Probe.js @@ -10,6 +10,7 @@ var utils = require('../utils'); */ function Crc32Probe() { GenericWorker.call(this, "Crc32Probe"); + this.withStreamInfo("crc32", 0); } utils.inherits(Crc32Probe, GenericWorker); diff --git a/test/asserts/load.js b/test/asserts/load.js index f043aef4..691b2eb6 100644 --- a/test/asserts/load.js +++ b/test/asserts/load.js @@ -473,6 +473,18 @@ QUnit.module("load", function () { }); } + JSZipTestUtils.testZipFile("valid crc32", "ref/all.zip", function(file) { + stop(); + JSZip.loadAsync(file, {checkCRC32:true}) + .then(function success() { + start(); + ok(true, "no exception were thrown"); + }, function failure(e) { + start(); + ok(false, "An exception were thrown: " + e.message); + }); + }); + QUnit.module("not supported features"); // zip -0 -X -e encrypted.zip Hello.txt