gunzip-maybe
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -14,10 +14,13 @@ var zlib = require('zlib') | ||
var gunzip = function () { | ||
var gunzip = function (maxRecursion) { | ||
if (!(maxRecursion >= 0)) maxRecursion = 3 | ||
return peek({newline: false, maxBuffer: 10}, function (data, swap) { | ||
if (maxRecursion < 0) return swap(new Error('Maximum recursion reached')) | ||
switch (isCompressed(data)) { | ||
case 1: | ||
swap(null, pumpify(zlib.createGunzip(), gunzip())) | ||
swap(null, pumpify(zlib.createGunzip(), gunzip(maxRecursion - 1))) | ||
break | ||
case 2: | ||
swap(null, pumpify(zlib.createInflate(), gunzip())) | ||
swap(null, pumpify(zlib.createInflate(), gunzip(maxRecursion - 1))) | ||
break | ||
@@ -24,0 +27,0 @@ default: |
{ | ||
"name": "gunzip-maybe", | ||
"description": "Transform stream that gunzips its input if it is gzipped and just echoes it if not", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -14,3 +14,4 @@ # gunzip-maybe | ||
Simply pipe a gzipped (or not gzipped) stream to `gunzip()` and read the unzipped content. | ||
Simply pipe a gzipped (or not gzipped) stream to `gunzip([maxRecursion = 3])` and read the unzipped content. | ||
`maxRecursion` protects the unzip mechanism from an infinite recursion in case of a malicious archive. | ||
@@ -17,0 +18,0 @@ ``` js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5735
93
36