From 0d27e9d9c075afcebdbf2eb2cdc9c3f31a2c41bb Mon Sep 17 00:00:00 2001 From: codedread Date: Tue, 21 Feb 2017 11:45:28 -0800 Subject: [PATCH] Fix unzipper so that it always gets a fresh buffer of data. Remove a debugger statement --- archive/archive.js | 2 +- archive/untar.js | 2 +- archive/unzip.js | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/archive/archive.js b/archive/archive.js index 8acc476..6ccc8b1 100644 --- a/archive/archive.js +++ b/archive/archive.js @@ -335,7 +335,7 @@ bitjs.archive.GetUnarchiver = function(ab, opt_pathToBitJS) { if (h[0] == 0x52 && h[1] == 0x61 && h[2] == 0x72 && h[3] == 0x21) { // Rar! unarchiver = new bitjs.archive.Unrarrer(ab, pathToBitJS); - } else if (h[0] == 80 && h[1] == 75) { // PK (Zip) + } else if (h[0] == 0x50 && h[1] == 0x4B) { // PK (Zip) unarchiver = new bitjs.archive.Unzipper(ab, pathToBitJS); } else { // Try with tar unarchiver = new bitjs.archive.Untarrer(ab, pathToBitJS); diff --git a/archive/untar.js b/archive/untar.js index 84b2c1e..5801279 100644 --- a/archive/untar.js +++ b/archive/untar.js @@ -62,7 +62,7 @@ class TarLocalFile { this.typeflag = readCleanString(bstream, 1); this.linkname = readCleanString(bstream, 100); this.maybeMagic = readCleanString(bstream, 6); -debugger; + if (this.maybeMagic == "ustar") { this.version = readCleanString(bstream, 2); this.uname = readCleanString(bstream, 32); diff --git a/archive/unzip.js b/archive/unzip.js index 4d4d231..c44a649 100644 --- a/archive/unzip.js +++ b/archive/unzip.js @@ -103,8 +103,7 @@ class ZipLocalFile { // read in the compressed data this.fileData = null; if (this.compressedSize > 0) { - this.fileData = new Uint8Array(bstream.bytes.buffer, bstream.ptr, this.compressedSize); - bstream.ptr += this.compressedSize; + this.fileData = new Uint8Array(bstream.readBytes(this.compressedSize)); } // TODO: deal with data descriptor if present (we currently assume no data descriptor!)