aboutsummaryrefslogtreecommitdiff
path: root/modules/ext/cryptogzip.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/ext/cryptogzip.js')
-rw-r--r--modules/ext/cryptogzip.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/ext/cryptogzip.js b/modules/ext/cryptogzip.js
index 25b6ca4..0bd4e71 100644
--- a/modules/ext/cryptogzip.js
+++ b/modules/ext/cryptogzip.js
@@ -137,11 +137,16 @@ class CryptoGzipModule {
}
try {
- const compressed = this._vfsRead(path);
- const content = await this._gunzipString(compressed);
+ // Binary-safe: a .gz written by `wget` lives in the VFS as raw Latin-1 bytes, and a .gz
+ // written by this module's own `gzip` lives there as base64 — _vfsReadBytes handles both.
+ // Going through _gunzipString (base64-only) made a real gzip file report
+ // "not valid base64 input (…)" instead of "not a gzip file".
+ const raw = this._vfsReadBytes(path);
+ if (!this._isGzip(raw)) throw new Error('not a gzip file');
+ const content = new TextDecoder().decode(await this._gunzipBytes(raw));
this._vfsWrite(outPath, content);
this._vfsDelete(path);
- this.terminal.print(`gunzipped: ${path} → ${outPath} (${compressed.length} → ${content.length} chars)`, 'success');
+ this.terminal.print(`gunzipped: ${path} → ${outPath} (${raw.length} → ${content.length} chars)`, 'success');
} catch (e) {
this.terminal.print('gunzip error: ' + e.message, 'error');
}