Socket
Socket
Sign inDemoInstall

unzipper

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unzipper - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

test/fileSizeUnknownFlag.js

19

lib/parse.js

@@ -85,3 +85,4 @@ var util = require('util');

this.pull(vars.extraFieldLength).then(extraField => {
var fileSizeKnown = !(vars.flags & 0x08);
var fileSizeKnown = !(vars.flags & 0x08),
eof;

@@ -94,11 +95,13 @@ var inflater = vars.compressionMethod ? zlib.createInflateRaw() : Stream.PassThrough();

entry.size = vars.uncompressedSize;
this.stream(vars.compressedSize)
.pipe(inflater)
.on('error', e => this.emit('error',err))
.pipe(entry)
.on('finish', () => this._readRecord());
eof = vars.compressedSize;
} else {
// TODO - allow pullstream to match
this.emit('error',new Error('MatchStream not implemented'));
eof = new Buffer(4);
eof.writeUInt32LE(0x08074b50, 0);
}
this.stream(eof)
.pipe(inflater)
.on('error', e => this.emit('error',err))
.pipe(entry)
.on('finish', () => fileSizeKnown ? this._readRecord() : this._processDataDescriptor(entry));
});

@@ -105,0 +108,0 @@ });

@@ -34,15 +34,32 @@ 'use strict';

PullStream.prototype.stream = function(len) {
// The `eof` parameter is interpreted as `file_length` if the type is number
// otherwise (i.e. buffer) it is interpreted as a pattern signaling end of stream
PullStream.prototype.stream = function(eof) {
const p = Stream.PassThrough();
let count = 0;
let count = 0,done,packet;
const pull = () => {
if (this.buffer && this.buffer.length) {
let packet = this.buffer.slice(0,len);
this.buffer = this.buffer.slice(len);
len -= packet.length;
if (typeof eof === 'number') {
packet = this.buffer.slice(0,eof);
this.buffer = this.buffer.slice(eof);
eof -= packet.length;
done = !eof;
} else {
let match = this.buffer.indexOf(eof);
if (match !== -1) {
packet = this.buffer.slice(0,match);
this.buffer = this.buffer.slice(match);
done = true;
} else {
let len = this.buffer.length - eof.length;
packet = this.buffer.slice(0,len);
this.buffer = this.buffer.slice(len);
}
}
p.write(packet);
}
if (len) {
if (!done) {
if (this.flushcb) {

@@ -49,0 +66,0 @@ this.removeListener('chunk',pull);

{
"name": "unzipper",
"version": "0.2.0",
"version": "0.3.0",
"description": "Unzip cross-platform streaming API ",

@@ -28,4 +28,3 @@ "author": "Evan Oxfeld <eoxfeld@gmail.com>",

"bluebird": "^3.4.1",
"fstream": "~1.0.10",
"readable-stream": "~1.0.31"
"fstream": "~1.0.10"
},

@@ -32,0 +31,0 @@ "devDependencies": {

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