Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compress-commons

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compress-commons - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

7

lib/archivers/zip/constants.js

@@ -37,3 +37,8 @@ /**

ZIP64_MAGIC_SHORT: 0xffff,
ZIP64_MAGIC: 0xffffffff
ZIP64_MAGIC: 0xffffffff,
ZLIB_NO_COMPRESSION: 0,
ZLIB_BEST_SPEED: 1,
ZLIB_BEST_COMPRESSION: 9,
ZLIB_DEFAULT_COMPRESSION: -1
};

8

lib/archivers/zip/general-purpose-bit.js

@@ -24,3 +24,3 @@ /**

this.encryption = false;
this.language = false;
this.utf8 = false;
this.numberOfShannonFanoTrees = 0;

@@ -36,3 +36,3 @@ this.strongEncryption = false;

(this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) |
(this.language ? UFT8_NAMES_FLAG : 0) |
(this.utf8 ? UFT8_NAMES_FLAG : 0) |
(this.encryption ? ENCRYPTION_FLAG : 0) |

@@ -98,7 +98,7 @@ (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0)

GeneralPurposeBit.prototype.useUTF8ForNames = function(b) {
this.language = b;
this.utf8 = b;
};
GeneralPurposeBit.prototype.usesUTF8ForNames = function() {
return this.language;
return this.utf8;
};

@@ -103,12 +103,10 @@ /**

ZipArchiveEntry.prototype.getTime = function(dos) {
dos = dos || false;
if (dos) {
return this.time;
}
ZipArchiveEntry.prototype.getTime = function() {
return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1;
};
ZipArchiveEntry.prototype.getTimeDos = function() {
return this.time !== -1 ? this.time : 0;
};
ZipArchiveEntry.prototype.getUnixMode = function() {

@@ -123,2 +121,6 @@ return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK);

ZipArchiveEntry.prototype.setComment = function(comment) {
if (Buffer.byteLength(comment) !== comment.length) {
this.getGeneralPurposeBit().useUTF8ForNames(true);
}
this.comment = comment;

@@ -172,4 +174,6 @@ };

ZipArchiveEntry.prototype.setName = function(name) {
if (name) {
name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
name = name.replace(/\\/g, '/').replace(/:/g, '').replace(/^\/+/, '');
if (Buffer.byteLength(name) !== name.length) {
this.getGeneralPurposeBit().useUTF8ForNames(true);
}

@@ -176,0 +180,0 @@

@@ -26,8 +26,7 @@ /**

options = options || {};
options.zlib = options.zlib || {};
options = this.options = options || {};
options.zlib = this._zlibDefaults(options.zlib);
ArchiveOutputStream.call(this, options);
this.options = options;
this._entry = null;

@@ -108,2 +107,3 @@ this._entries = [];

this._archive.processing = false;
this._archive.finish = true;

@@ -119,2 +119,7 @@ this._archive.finished = true;

if (ae.getMethod() === constants.METHOD_DEFLATED) {
ae.getGeneralPurposeBit().useDataDescriptor(true);
ae.setVersionNeededToExtract(constants.DATA_DESCRIPTOR_MIN_VERSION);
}
if (ae.getTime() === -1) {

@@ -192,3 +197,3 @@ ae.setTime(new Date());

// datetime
this.write(zipUtil.getLongBytes(zae.getTime(true)));
this.write(zipUtil.getLongBytes(zae.getTimeDos()));

@@ -238,5 +243,3 @@ // crc32 checksum

ZipArchiveOutputStream.prototype._writeDataDescriptor = function(zae) {
var gpb = zae.getGeneralPurposeBit();
if (!gpb.usesDataDescriptor()) {
if (zae.getGeneralPurposeBit().usesDataDescriptor()) {
return;

@@ -257,3 +260,2 @@ }

ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(zae) {
var gpb = zae.getGeneralPurposeBit();
var method = zae.getMethod();

@@ -275,7 +277,7 @@ var name = zae.getName();

// datetime
this.write(zipUtil.getLongBytes(zae.getTime(true)));
this.write(zipUtil.getLongBytes(zae.getTimeDos()));
zae._offsets.data = this.offset;
if (method == constants.METHOD_DEFLATED || gpb.usesDataDescriptor()) {
if (zae.getGeneralPurposeBit().usesDataDescriptor()) {
// zero fill and set later

@@ -308,14 +310,16 @@ this.write(constants.LONG_ZERO);

ZipArchiveOutputStream.prototype._writeVersionGeneral = function(zae) {
var method = zae.getMethod();
var verex = zae.getVersionNeededToExtract();
var gpb = zae.getGeneralPurposeBit();
this.write(zipUtil.getShortBytes(zae.getVersionNeededToExtract()));
this.write(zae.getGeneralPurposeBit().encode());
};
if (method == constants.METHOD_DEFLATED) {
verex = constants.DATA_DESCRIPTOR_MIN_VERSION;
zae.setVersionNeededToExtract(verex);
gpb.useDataDescriptor(true);
ZipArchiveOutputStream.prototype._zlibDefaults = function(o) {
if (typeof o !== 'object') {
o = {};
}
this.write(zipUtil.getShortBytes(verex));
this.write(gpb.encode());
if (typeof o.level !== 'number') {
o.level = constants.ZLIB_BEST_SPEED;
}
return o;
};

@@ -322,0 +326,0 @@

{
"name": "compress-commons",
"version": "0.1.0",
"version": "0.1.1",
"description": "a library that defines a common interface for working with archives within node",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-compress-commons",

@@ -1,2 +0,2 @@

# Compress Commons v0.1.0 [![Build Status](https://travis-ci.org/ctalkington/node-compress-commons.svg?branch=master)](https://travis-ci.org/ctalkington/node-compress-commons)
# Compress Commons v0.1.1 [![Build Status](https://travis-ci.org/ctalkington/node-compress-commons.svg?branch=master)](https://travis-ci.org/ctalkington/node-compress-commons)

@@ -17,2 +17,3 @@ Compress Commons is a library that defines a common interface for working with archives within node.

- [Source Docs (coming soon)](https://docsrc.com/compress-commons/)
- [Changelog](https://github.com/ctalkington/node-compress-commons/releases)

@@ -19,0 +20,0 @@ - [Contributing](https://github.com/ctalkington/node-compress-commons/blob/master/CONTRIBUTING.md)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc