From 1fe5755b4192f1ce48b7c0a5f5e253881df22521 Mon Sep 17 00:00:00 2001 From: Tomer Mansur Date: Thu, 6 Apr 2017 15:18:13 +0300 Subject: [PATCH] explicitly reject on wrong password --- lib/extract.js | 6 ++++++ lib/extractFull.js | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/extract.js b/lib/extract.js index fdbbfd5..cb2e993 100644 --- a/lib/extract.js +++ b/lib/extract.js @@ -38,6 +38,12 @@ module.exports = function (archive, dest, options) { if (isUnsupportedMethod) { return reject(new Error('Unsupported Method')) } + let isWrongPassword = (data.search('Data Error in encrypted file. Wrong password?') != -1) + ? true + : false; + if (isWrongPassword) { + return reject(new Error('Data Error in encrypted file. Wrong password?')); + } data.split('\n').forEach(function (line) { if (line.substr(0, 12) === 'Extracting ') { diff --git a/lib/extractFull.js b/lib/extractFull.js index d4137c0..5a78233 100644 --- a/lib/extractFull.js +++ b/lib/extractFull.js @@ -36,10 +36,15 @@ module.exports = function (archive, dest, options) { ? true : false; if (isUnsupportedMethod) { - return reject(new Error('Unsupported Method')) + return reject(new Error('Unsupported Method')); + } + let isWrongPassword = (data.search('Data Error in encrypted file. Wrong password?') != -1) + ? true + : false; + if (isWrongPassword) { + return reject(new Error('Data Error in encrypted file. Wrong password?')); } - var entries = []; data.split('\n').forEach(function (line) { if (line.substr(0, 12) === 'Extracting ') { entries.push(line.substr(12, line.length).replace(path.sep, '/'));