From 8439bbf117eb5270d6a6cc9888bfc16d90cb29a8 Mon Sep 17 00:00:00 2001 From: David Tuite Date: Fri, 6 Nov 2015 22:32:28 +0000 Subject: [PATCH] Don't use octal numbers When run with the "--use_strict" flag, NodeJS raises an error citing: SyntaxError: Octal literals are not allowed in strict mode. when parsing files which contain Octal numbers (or numbers which look like octals - usually because they have leading zeros). This commit replaces two instances of this with strings. See [this Stack Overflow answer](http://stackoverflow.com/a/23609255/574190) for more info. --- headers.js | 2 +- pack.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/headers.js b/headers.js index 992be10..e688f93 100644 --- a/headers.js +++ b/headers.js @@ -166,7 +166,7 @@ exports.encode = function(opts) { if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null buf.write(name) - buf.write(encodeOct(opts.mode & 07777, 6), 100) + buf.write(encodeOct(opts.mode & parseInt('07777', 8), 6), 100) buf.write(encodeOct(opts.uid, 6), 108) buf.write(encodeOct(opts.gid, 6), 116) buf.write(encodeOct(opts.size, 11), 124) diff --git a/pack.js b/pack.js index 556055e..043f28d 100644 --- a/pack.js +++ b/pack.js @@ -118,7 +118,7 @@ Pack.prototype.entry = function(header, buffer, callback) { if (!header.size) header.size = 0 if (!header.type) header.type = modeToType(header.mode) - if (!header.mode) header.mode = header.type === 'directory' ? 0755 : 0644 + if (!header.mode) header.mode = parseInt(header.type === 'directory' ? '0755' : '0644') if (!header.uid) header.uid = 0 if (!header.gid) header.gid = 0 if (!header.mtime) header.mtime = new Date()