forked from olcxjas-softworks/LarpixClient
update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
43
electron/node_modules/tar/dist/commonjs/parse.js
generated
vendored
43
electron/node_modules/tar/dist/commonjs/parse.js
generated
vendored
|
|
@ -60,6 +60,10 @@ const SAW_VALID_ENTRY = Symbol('sawValidEntry');
|
|||
const SAW_NULL_BLOCK = Symbol('sawNullBlock');
|
||||
const SAW_EOF = Symbol('sawEOF');
|
||||
const CLOSESTREAM = Symbol('closeStream');
|
||||
const MAX_DECOMPRESSION_RATIO = 1000;
|
||||
const COMPRESSEDBYTESREAD = Symbol('compressedBytesRead');
|
||||
const DECOMPRESSEDBYTESREAD = Symbol('decompressedBytesRead');
|
||||
const CHECKDECOMPRESSIONRATIO = Symbol('checkDecompressionRatio');
|
||||
const noop = () => true;
|
||||
class Parser extends events_1.EventEmitter {
|
||||
file;
|
||||
|
|
@ -68,6 +72,7 @@ class Parser extends events_1.EventEmitter {
|
|||
filter;
|
||||
brotli;
|
||||
zstd;
|
||||
maxDecompressionRatio;
|
||||
writable = true;
|
||||
readable = false;
|
||||
[QUEUE] = [];
|
||||
|
|
@ -87,6 +92,8 @@ class Parser extends events_1.EventEmitter {
|
|||
[WRITING] = false;
|
||||
[CONSUMING] = false;
|
||||
[EMITTEDEND] = false;
|
||||
[COMPRESSEDBYTESREAD] = 0;
|
||||
[DECOMPRESSEDBYTESREAD] = 0;
|
||||
constructor(opt = {}) {
|
||||
super();
|
||||
this.file = opt.file || '';
|
||||
|
|
@ -109,6 +116,10 @@ class Parser extends events_1.EventEmitter {
|
|||
});
|
||||
}
|
||||
this.strict = !!opt.strict;
|
||||
this.maxDecompressionRatio =
|
||||
typeof opt.maxDecompressionRatio === 'number' ?
|
||||
opt.maxDecompressionRatio
|
||||
: MAX_DECOMPRESSION_RATIO;
|
||||
this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize;
|
||||
this.filter = typeof opt.filter === 'function' ? opt.filter : noop;
|
||||
// Unlike gzip, brotli doesn't have any magic bytes to identify it
|
||||
|
|
@ -362,11 +373,23 @@ class Parser extends events_1.EventEmitter {
|
|||
}
|
||||
}
|
||||
abort(error) {
|
||||
if (this[ABORTED]) {
|
||||
return;
|
||||
}
|
||||
this[ABORTED] = true;
|
||||
this.emit('abort', error);
|
||||
// always throws, even in non-strict mode
|
||||
this.warn('TAR_ABORT', error, { recoverable: false });
|
||||
}
|
||||
[CHECKDECOMPRESSIONRATIO](chunk) {
|
||||
this[DECOMPRESSEDBYTESREAD] += chunk.length;
|
||||
const ratio = this[DECOMPRESSEDBYTESREAD] / this[COMPRESSEDBYTESREAD];
|
||||
if (ratio > this.maxDecompressionRatio) {
|
||||
this.abort(new Error(`max decompression ratio exceeded: ${ratio.toFixed(2)} > ${this.maxDecompressionRatio}`));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
write(chunk, encoding, cb) {
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
|
|
@ -450,13 +473,22 @@ class Parser extends events_1.EventEmitter {
|
|||
this[UNZIP] === undefined ? new minizlib_1.Unzip({})
|
||||
: isZstd ? new minizlib_1.ZstdDecompress({})
|
||||
: new minizlib_1.BrotliDecompress({});
|
||||
this[UNZIP].on('data', chunk => this[CONSUMECHUNK](chunk));
|
||||
this[UNZIP].on('error', er => this.abort(er));
|
||||
this[UNZIP].on('data', chunk => {
|
||||
if (this[CHECKDECOMPRESSIONRATIO](chunk)) {
|
||||
this[CONSUMECHUNK](chunk);
|
||||
}
|
||||
});
|
||||
this[UNZIP].on('error', er => {
|
||||
if (!this[ABORTED]) {
|
||||
this.abort(er);
|
||||
}
|
||||
});
|
||||
this[UNZIP].on('end', () => {
|
||||
this[ENDED] = true;
|
||||
this[CONSUMECHUNK]();
|
||||
});
|
||||
this[WRITING] = true;
|
||||
this[COMPRESSEDBYTESREAD] += chunk.length;
|
||||
const ret = !!this[UNZIP][ended ? 'end' : 'write'](chunk);
|
||||
this[WRITING] = false;
|
||||
cb?.();
|
||||
|
|
@ -465,6 +497,7 @@ class Parser extends events_1.EventEmitter {
|
|||
}
|
||||
this[WRITING] = true;
|
||||
if (this[UNZIP]) {
|
||||
this[COMPRESSEDBYTESREAD] += chunk.length;
|
||||
this[UNZIP].write(chunk);
|
||||
}
|
||||
else {
|
||||
|
|
@ -495,7 +528,7 @@ class Parser extends events_1.EventEmitter {
|
|||
!this[CONSUMING]) {
|
||||
this[EMITTEDEND] = true;
|
||||
const entry = this[WRITEENTRY];
|
||||
if (entry && entry.blockRemain) {
|
||||
if (entry?.blockRemain) {
|
||||
// truncated, likely a damaged file
|
||||
const have = this[BUFFER] ? this[BUFFER].length : 0;
|
||||
this.warn('TAR_BAD_ARCHIVE', `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`, { entry });
|
||||
|
|
@ -589,8 +622,10 @@ class Parser extends events_1.EventEmitter {
|
|||
if (!this[ABORTED]) {
|
||||
if (this[UNZIP]) {
|
||||
/* c8 ignore start */
|
||||
if (chunk)
|
||||
if (chunk) {
|
||||
this[COMPRESSEDBYTESREAD] += chunk.length;
|
||||
this[UNZIP].write(chunk);
|
||||
}
|
||||
/* c8 ignore stop */
|
||||
this[UNZIP].end();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue