@poe-platform/safe-bash 0.1.615 → 0.1.617
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-bash/chunks/{chunk-PW4WQSCS.js → chunk-3M5F7LD5.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-CEPNDODE.js → chunk-4DBWBEU7.js} +2 -2
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js → chunk-KYNRHYHP.js} +4 -4
- package/dist/safe-bash/chunks/{chunk-PFMSKAFQ.js.map → chunk-KYNRHYHP.js.map} +2 -2
- package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js → chunk-X55AMTNM.js} +2 -2
- package/dist/safe-bash/commands/archive/unzip.js +1 -1
- package/dist/safe-bash/commands/archive/unzip.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip/safety.d.ts +2 -0
- package/dist/safe-bash/commands/archive/zip/safety.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip/safety.js +4 -0
- package/dist/safe-bash/commands/archive/zip/safety.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts +10 -0
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js +93 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip-format.d.ts +2 -2
- package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.js +69 -48
- package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +83 -34
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
- package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
- package/dist/safe-bash/commands/network/index.browser.js +2 -2
- package/dist/safe-bash/commands/network/output.js +2 -2
- package/dist/safe-bash/commands/network/output.js.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.d.ts +3 -1
- package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.js +2 -1
- package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
- package/dist/safe-bash/core.browser.js +214 -73
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/package.json +2 -2
- package/dist/safe-bash/chunks/chunk-CEPNDODE.js.map +0 -7
- /package/dist/safe-bash/chunks/{chunk-PW4WQSCS.js.map → chunk-3M5F7LD5.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-F5TCC4UG.js.map → chunk-X55AMTNM.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem-output.js","sourceRoot":"","sources":["../../src/contracts/filesystem-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiD,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAgF,CAAC;
|
|
1
|
+
{"version":3,"file":"filesystem-output.js","sourceRoot":"","sources":["../../src/contracts/filesystem-output.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiD,MAAM,SAAS,CAAC;AACvG,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAgF,CAAC;AAM5H,MAAM,UAAU,oBAAoB,CAAC,OAAgD,EAAE,MAAoC;IACzH,IAAI,CAAC,OAAO,CAAC,eAAe;QAAE,MAAM,IAAI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ineEndingCommands
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-X55AMTNM.js";
|
|
38
38
|
import {
|
|
39
39
|
createLlmCommands,
|
|
40
40
|
llmCommands
|
|
@@ -86,7 +86,7 @@ import {
|
|
|
86
86
|
curlCommands,
|
|
87
87
|
defaultNetworkLimits,
|
|
88
88
|
networkCommands
|
|
89
|
-
} from "./chunks/chunk-
|
|
89
|
+
} from "./chunks/chunk-KYNRHYHP.js";
|
|
90
90
|
import {
|
|
91
91
|
RecordBuffer,
|
|
92
92
|
UsageError,
|
|
@@ -138,12 +138,12 @@ import {
|
|
|
138
138
|
exprMatchCeilings,
|
|
139
139
|
matchEre,
|
|
140
140
|
withRegexSession
|
|
141
|
-
} from "./chunks/chunk-
|
|
141
|
+
} from "./chunks/chunk-3M5F7LD5.js";
|
|
142
142
|
import {
|
|
143
143
|
bindFileOutputBudget,
|
|
144
144
|
openFileOutput,
|
|
145
145
|
writeFileOutput
|
|
146
|
-
} from "./chunks/chunk-
|
|
146
|
+
} from "./chunks/chunk-4DBWBEU7.js";
|
|
147
147
|
import {
|
|
148
148
|
createOutputOperation
|
|
149
149
|
} from "./chunks/chunk-RNKTWFEM.js";
|
|
@@ -26614,6 +26614,82 @@ init_platform();
|
|
|
26614
26614
|
|
|
26615
26615
|
// packages/safe-bash/src/commands/archive/zip-format.ts
|
|
26616
26616
|
init_platform();
|
|
26617
|
+
|
|
26618
|
+
// packages/safe-bash/src/commands/archive/zip/zip64.ts
|
|
26619
|
+
init_platform();
|
|
26620
|
+
function wide(view, offset) {
|
|
26621
|
+
if (offset < 0 || offset + 8 > view.byteLength) fail("ZIP64 truncated numeric field");
|
|
26622
|
+
const value2 = view.getBigUint64(offset, true);
|
|
26623
|
+
if (value2 > BigInt(Number.MAX_SAFE_INTEGER)) fail("ZIP64 unsafe numeric field");
|
|
26624
|
+
return Number(value2);
|
|
26625
|
+
}
|
|
26626
|
+
function zip64Directory(view, end, limits) {
|
|
26627
|
+
let members = view.getUint16(end + 10, true);
|
|
26628
|
+
let centralSize = view.getUint32(end + 12, true);
|
|
26629
|
+
let centralStart = view.getUint32(end + 16, true);
|
|
26630
|
+
let centralEnd = end;
|
|
26631
|
+
const diskMembers = view.getUint16(end + 8, true);
|
|
26632
|
+
if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true)) fail("ZIP multi-disk archive is unsupported");
|
|
26633
|
+
const locator = end >= 20 && view.getUint32(end - 20, true) === 117853008;
|
|
26634
|
+
if (locator) {
|
|
26635
|
+
if (view.getUint32(end - 16, true) || view.getUint32(end - 4, true) !== 1) fail("ZIP64 multi-disk locator is unsupported");
|
|
26636
|
+
centralEnd = wide(view, end - 12);
|
|
26637
|
+
if (centralEnd + 56 > end - 20 || view.getUint32(centralEnd, true) !== 101075792) fail("ZIP64 invalid end-record span");
|
|
26638
|
+
const length = wide(view, centralEnd + 4);
|
|
26639
|
+
if (length < 44 || length - 44 > limits.maxPaxBytes || centralEnd + 12 + length !== end - 20) fail("ZIP64 invalid end-record length");
|
|
26640
|
+
if (view.getUint16(centralEnd + 14, true) !== 45) fail("ZIP64 unsupported end-record extraction version");
|
|
26641
|
+
if (view.getUint32(centralEnd + 16, true) || view.getUint32(centralEnd + 20, true)) fail("ZIP64 multi-disk archive is unsupported");
|
|
26642
|
+
const count2 = wide(view, centralEnd + 32);
|
|
26643
|
+
if (wide(view, centralEnd + 24) !== count2 || members !== 65535 && members !== count2 || diskMembers !== 65535 && diskMembers !== count2) fail("ZIP64 inconsistent member count");
|
|
26644
|
+
const size = wide(view, centralEnd + 40);
|
|
26645
|
+
const start = wide(view, centralEnd + 48);
|
|
26646
|
+
if (centralSize !== 4294967295 && centralSize !== size || centralStart !== 4294967295 && centralStart !== start) fail("ZIP64 inconsistent central directory");
|
|
26647
|
+
members = count2;
|
|
26648
|
+
centralSize = size;
|
|
26649
|
+
centralStart = start;
|
|
26650
|
+
} else if (members === 65535 || centralSize === 4294967295 || centralStart === 4294967295) fail("ZIP64 missing end record and locator");
|
|
26651
|
+
else if (diskMembers !== members) fail("ZIP inconsistent member count");
|
|
26652
|
+
if (members > limits.maxMembers) fail("ZIP member limit exceeded");
|
|
26653
|
+
if (centralStart > limits.maxArchiveBytes || centralSize > limits.maxArchiveBytes || centralStart + centralSize !== centralEnd) fail("ZIP invalid central directory span");
|
|
26654
|
+
return { members, centralStart, centralSize, centralEnd };
|
|
26655
|
+
}
|
|
26656
|
+
function zip64Fields(data2, values) {
|
|
26657
|
+
let offset = 0;
|
|
26658
|
+
const view = data2 && new DataView(data2.buffer, data2.byteOffset, data2.byteLength);
|
|
26659
|
+
return values.map((value2, index) => {
|
|
26660
|
+
if (value2 !== 4294967295) return value2;
|
|
26661
|
+
if (!view) fail("ZIP64 missing required extra field");
|
|
26662
|
+
const width = index === 3 ? 4 : 8;
|
|
26663
|
+
if (offset + width > view.byteLength) fail("ZIP64 truncated extra field");
|
|
26664
|
+
const resolved = width === 4 ? view.getUint32(offset, true) : wide(view, offset);
|
|
26665
|
+
offset += width;
|
|
26666
|
+
return resolved;
|
|
26667
|
+
});
|
|
26668
|
+
}
|
|
26669
|
+
function stripZip64(bytes3) {
|
|
26670
|
+
const view = new DataView(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength);
|
|
26671
|
+
const retained = [];
|
|
26672
|
+
let length = 0;
|
|
26673
|
+
for (let offset2 = 0; offset2 < bytes3.length; ) {
|
|
26674
|
+
if (offset2 + 4 > bytes3.length) fail("ZIP truncated extra field");
|
|
26675
|
+
const next = offset2 + 4 + view.getUint16(offset2 + 2, true);
|
|
26676
|
+
if (next > bytes3.length) fail("ZIP truncated extra field payload");
|
|
26677
|
+
if (view.getUint16(offset2, true) !== 1) {
|
|
26678
|
+
retained.push(bytes3.subarray(offset2, next));
|
|
26679
|
+
length += next - offset2;
|
|
26680
|
+
}
|
|
26681
|
+
offset2 = next;
|
|
26682
|
+
}
|
|
26683
|
+
const result = new Uint8Array(length);
|
|
26684
|
+
let offset = 0;
|
|
26685
|
+
for (const field2 of retained) {
|
|
26686
|
+
result.set(field2, offset);
|
|
26687
|
+
offset += field2.length;
|
|
26688
|
+
}
|
|
26689
|
+
return result;
|
|
26690
|
+
}
|
|
26691
|
+
|
|
26692
|
+
// packages/safe-bash/src/commands/archive/zip-format.ts
|
|
26617
26693
|
var encoder2 = new TextEncoder();
|
|
26618
26694
|
var cp437 = "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
|
|
26619
26695
|
var crcTable4 = Uint32Array.from({ length: 256 }, (_, index) => {
|
|
@@ -26670,7 +26746,10 @@ function extras(bytes3, rawName, comment2, central, limits) {
|
|
|
26670
26746
|
if (offset + length > bytes3.length) fail("ZIP truncated extra field payload");
|
|
26671
26747
|
if (seen.has(identifier)) fail("ZIP duplicate extra field");
|
|
26672
26748
|
seen.add(identifier);
|
|
26673
|
-
if (identifier === 1)
|
|
26749
|
+
if (identifier === 1) {
|
|
26750
|
+
if (!length || length > 28 || length % 4) fail("ZIP64 invalid extra field length");
|
|
26751
|
+
result.zip64 = bytes3.subarray(offset, offset + length);
|
|
26752
|
+
}
|
|
26674
26753
|
if (identifier === 39169 || identifier === 23 || identifier === 24 || identifier === 25) fail("ZIP encryption is unsupported");
|
|
26675
26754
|
if (identifier === 28789 || identifier === 25461) {
|
|
26676
26755
|
if (length < 5 || bytes3[offset] !== 1) fail("ZIP unsupported or truncated Unicode extra field");
|
|
@@ -26706,7 +26785,7 @@ function format(method, flags3, version) {
|
|
|
26706
26785
|
if (flags3 & (1 | 64 | 8192)) fail("ZIP encryption is unsupported");
|
|
26707
26786
|
if (flags3 & ~2062 || method === 0 && flags3 & 6) fail("ZIP unsupported general purpose flags");
|
|
26708
26787
|
if (method !== 0 && method !== 8) fail("ZIP unsupported compression method");
|
|
26709
|
-
if (version < (method === 8 || flags3 & 8 ? 20 : 10) || version > 20) fail("ZIP unsupported extraction version (including ZIP64)");
|
|
26788
|
+
if (version < (method === 8 || flags3 & 8 ? 20 : 10) || version > 20 && version !== 45) fail("ZIP unsupported extraction version (including ZIP64)");
|
|
26710
26789
|
}
|
|
26711
26790
|
function dosModified(date2, time) {
|
|
26712
26791
|
if (!date2 && !time) return new Date(1980, 0, 1);
|
|
@@ -26729,7 +26808,8 @@ function entryBounds(entry, limits) {
|
|
|
26729
26808
|
format(entry.method, entry.flags ?? 2048, entry.method === 8 || (entry.flags ?? 0) & 8 ? 20 : 10);
|
|
26730
26809
|
if (entry.directory !== entry.name.endsWith("/") || entry.directory && (entry.symlink || entry.size !== 0)) fail("ZIP inconsistent directory metadata");
|
|
26731
26810
|
const type = entry.mode & 61440;
|
|
26732
|
-
|
|
26811
|
+
const pipePayload = !entry.directory && !entry.symlink && type === 4096;
|
|
26812
|
+
if (type !== 0 && !pipePayload && type !== (entry.directory ? 16384 : entry.symlink ? 40960 : 32768)) fail("ZIP unsupported or conflicting file type");
|
|
26733
26813
|
if (!Number.isFinite(entry.modified.getTime())) fail("ZIP invalid modification time");
|
|
26734
26814
|
}
|
|
26735
26815
|
async function copyBytes(source2, destination2, start, chunkSize2, signal) {
|
|
@@ -26757,13 +26837,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26757
26837
|
}
|
|
26758
26838
|
}
|
|
26759
26839
|
if (end === -1) fail("ZIP truncated or missing end of central directory");
|
|
26760
|
-
const members = view
|
|
26761
|
-
const centralSize = view.getUint32(end + 12, true);
|
|
26762
|
-
const centralStart = view.getUint32(end + 16, true);
|
|
26763
|
-
if (members === 65535 || centralSize === 4294967295 || centralStart === 4294967295) fail("ZIP64 is unsupported");
|
|
26764
|
-
if (view.getUint16(end + 4, true) || view.getUint16(end + 6, true) || view.getUint16(end + 8, true) !== members) fail("ZIP multi-disk or inconsistent member count is unsupported");
|
|
26765
|
-
if (centralStart + centralSize !== end) fail("ZIP invalid central directory span or unsupported ZIP64/trailing records");
|
|
26766
|
-
number3(members, limits.maxMembers, "member");
|
|
26840
|
+
const { members, centralStart, centralEnd } = zip64Directory(view, end, limits);
|
|
26767
26841
|
number3(bytes3.length - end - 22, limits.maxTextBytes, "archive comment");
|
|
26768
26842
|
const entries2 = [];
|
|
26769
26843
|
const spans = [];
|
|
@@ -26771,7 +26845,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26771
26845
|
let total = 0;
|
|
26772
26846
|
for (let index = 0; index < members; index++) {
|
|
26773
26847
|
await yieldTurn(signal);
|
|
26774
|
-
if (offset + 46 >
|
|
26848
|
+
if (offset + 46 > centralEnd || view.getUint32(offset, true) !== 33639248) fail("ZIP truncated or invalid central header");
|
|
26775
26849
|
const versionMadeBy = view.getUint16(offset + 4, true);
|
|
26776
26850
|
const version = view.getUint16(offset + 6, true);
|
|
26777
26851
|
const flags3 = view.getUint16(offset + 8, true);
|
|
@@ -26780,29 +26854,32 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26780
26854
|
const dosTime = view.getUint16(offset + 12, true);
|
|
26781
26855
|
const dosDate = view.getUint16(offset + 14, true);
|
|
26782
26856
|
const checksum = view.getUint32(offset + 16, true);
|
|
26783
|
-
|
|
26784
|
-
|
|
26857
|
+
let compressedSize = view.getUint32(offset + 20, true);
|
|
26858
|
+
let size = view.getUint32(offset + 24, true);
|
|
26785
26859
|
const nameLength = view.getUint16(offset + 28, true);
|
|
26786
26860
|
const extraLength = view.getUint16(offset + 30, true);
|
|
26787
26861
|
const commentLength = view.getUint16(offset + 32, true);
|
|
26788
26862
|
const internalAttributes = view.getUint16(offset + 36, true);
|
|
26789
26863
|
if (internalAttributes & ~1) fail("ZIP unsupported internal attributes");
|
|
26790
26864
|
const externalAttributes = view.getUint32(offset + 38, true);
|
|
26791
|
-
|
|
26792
|
-
|
|
26793
|
-
if (compressedSize === 4294967295 || size === 4294967295 || local === 4294967295) fail("ZIP64 is unsupported");
|
|
26794
|
-
number3(size, limits.maxEntryBytes, "entry byte");
|
|
26795
|
-
if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
|
|
26796
|
-
total += size;
|
|
26797
|
-
number3(total, limits.maxTotalBytes, "total byte");
|
|
26865
|
+
let local = view.getUint32(offset + 42, true);
|
|
26866
|
+
const disk = view.getUint16(offset + 34, true);
|
|
26798
26867
|
const next = offset + 46 + nameLength + extraLength + commentLength;
|
|
26799
|
-
if (next >
|
|
26868
|
+
if (next > centralEnd) fail("ZIP truncated central metadata");
|
|
26800
26869
|
number3(commentLength, limits.maxTextBytes, "entry comment");
|
|
26801
26870
|
const rawName = bytes3.subarray(offset + 46, offset + 46 + nameLength);
|
|
26802
26871
|
const centralExtra = bytes3.subarray(offset + 46 + nameLength, next - commentLength);
|
|
26803
26872
|
const comment2 = bytes3.subarray(next - commentLength, next);
|
|
26804
26873
|
if (flags3 & 2048) text2(comment2);
|
|
26805
26874
|
const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
|
|
26875
|
+
const resolved = zip64Fields(centralMetadata.zip64, [size, compressedSize, local, disk === 65535 ? 4294967295 : disk]);
|
|
26876
|
+
[size, compressedSize, local] = resolved;
|
|
26877
|
+
if (resolved[3]) fail("ZIP multi-disk member is unsupported");
|
|
26878
|
+
number3(size, limits.maxEntryBytes, "entry byte");
|
|
26879
|
+
number3(compressedSize, limits.maxArchiveBytes, "compressed entry byte");
|
|
26880
|
+
if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
|
|
26881
|
+
total += size;
|
|
26882
|
+
number3(total, limits.maxTotalBytes, "total byte");
|
|
26806
26883
|
const name2 = nameFrom(rawName, flags3, centralMetadata, limits);
|
|
26807
26884
|
if (local + 30 > centralStart || view.getUint32(local, true) !== 67324752) fail("ZIP invalid local header span");
|
|
26808
26885
|
if (view.getUint16(local + 4, true) !== version || view.getUint16(local + 6, true) !== flags3 || view.getUint16(local + 8, true) !== method || view.getUint16(local + 10, true) !== dosTime || view.getUint16(local + 12, true) !== dosDate) fail("ZIP central/local metadata mismatch");
|
|
@@ -26818,15 +26895,22 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26818
26895
|
const localEffective = nameFrom(localName, flags3, localMetadata, limits);
|
|
26819
26896
|
if (localMetadata.name !== void 0 && localEffective !== name2) fail("ZIP central/local Unicode name mismatch");
|
|
26820
26897
|
if (centralMetadata.modified !== void 0 && localMetadata.modified !== void 0 && centralMetadata.modified !== localMetadata.modified) fail("ZIP central/local timestamp mismatch");
|
|
26821
|
-
|
|
26822
|
-
|
|
26898
|
+
const rawLocalSize = view.getUint32(local + 22, true);
|
|
26899
|
+
const rawLocalCompressed = view.getUint32(local + 18, true);
|
|
26900
|
+
const [localSize, localCompressed] = zip64Fields(localMetadata.zip64, [rawLocalSize, rawLocalCompressed]);
|
|
26901
|
+
for (const [actual, expected] of [[view.getUint32(local + 14, true), checksum], [localCompressed, compressedSize], [localSize, size]]) {
|
|
26823
26902
|
if (actual !== expected && (!(flags3 & 8) || actual !== 0)) fail("ZIP central/local size or CRC mismatch");
|
|
26824
26903
|
}
|
|
26825
26904
|
if (flags3 & 8) {
|
|
26826
26905
|
const matches2 = [];
|
|
26827
26906
|
for (const signed2 of [false, true]) {
|
|
26828
26907
|
const descriptor = payloadEnd + (signed2 ? 4 : 0);
|
|
26829
|
-
|
|
26908
|
+
const wide2 = rawLocalSize === 4294967295 || rawLocalCompressed === 4294967295;
|
|
26909
|
+
const length = wide2 ? 20 : 12;
|
|
26910
|
+
if (descriptor + length > centralStart || signed2 && view.getUint32(payloadEnd, true) !== 134695760 || view.getUint32(descriptor, true) !== checksum) continue;
|
|
26911
|
+
const compressed2 = wide2 ? view.getBigUint64(descriptor + 4, true) : BigInt(view.getUint32(descriptor + 4, true));
|
|
26912
|
+
const expanded = wide2 ? view.getBigUint64(descriptor + 12, true) : BigInt(view.getUint32(descriptor + 8, true));
|
|
26913
|
+
if (compressed2 === BigInt(compressedSize) && expanded === BigInt(size)) matches2.push(descriptor + length);
|
|
26830
26914
|
}
|
|
26831
26915
|
if (matches2.length !== 1) fail("ZIP truncated, ambiguous or mismatched data descriptor");
|
|
26832
26916
|
payloadEnd = matches2[0];
|
|
@@ -26846,7 +26930,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26846
26930
|
spans.push({ start: local, end: payloadEnd });
|
|
26847
26931
|
offset = next;
|
|
26848
26932
|
}
|
|
26849
|
-
if (offset !==
|
|
26933
|
+
if (offset !== centralEnd) fail("ZIP central directory size or member count mismatch");
|
|
26850
26934
|
spans.sort((first, second) => first.start - second.start);
|
|
26851
26935
|
let covered = 0;
|
|
26852
26936
|
for (const span of spans) {
|
|
@@ -26896,7 +26980,7 @@ async function* decodeZipEntry(entry, limits, signal) {
|
|
|
26896
26980
|
await reader.close();
|
|
26897
26981
|
}
|
|
26898
26982
|
}
|
|
26899
|
-
async function makeZipEntry(name2, bytes3, attributes, limits, signal, level = 6) {
|
|
26983
|
+
async function makeZipEntry(name2, bytes3, attributes, limits, signal, level = 6, forceCompression = false) {
|
|
26900
26984
|
const chunkSize2 = admit(limits, signal);
|
|
26901
26985
|
const entry = { name: name2, data: bytes3, size: bytes3.length, method: 0, crc32: 0, ...attributes, modified: new Date(attributes.modified.getTime()) };
|
|
26902
26986
|
entryBounds(entry, limits);
|
|
@@ -26908,15 +26992,16 @@ async function makeZipEntry(name2, bytes3, attributes, limits, signal, level = 6
|
|
|
26908
26992
|
yield bytes3;
|
|
26909
26993
|
})(), signal);
|
|
26910
26994
|
try {
|
|
26911
|
-
if (level !== 0 && bytes3.length && !entry.directory && !entry.symlink) {
|
|
26995
|
+
if (level !== 0 && (bytes3.length || forceCompression) && !entry.directory && !entry.symlink) {
|
|
26912
26996
|
const chunks = [];
|
|
26913
26997
|
let length = 0;
|
|
26914
26998
|
for await (const chunk of codec(reader, { mode: "deflate-raw", chunkSize: chunkSize2, level }, signal)) {
|
|
26915
26999
|
length += chunk.length;
|
|
26916
|
-
if (length
|
|
27000
|
+
if (length > limits.maxArchiveBytes) fail("ZIP compressed byte limit exceeded");
|
|
27001
|
+
if (!forceCompression && length >= bytes3.length) break;
|
|
26917
27002
|
chunks.push(new Uint8Array(chunk));
|
|
26918
27003
|
}
|
|
26919
|
-
if (length < bytes3.length) {
|
|
27004
|
+
if (forceCompression || length < bytes3.length) {
|
|
26920
27005
|
entry.data = new Uint8Array(length);
|
|
26921
27006
|
let offset = 0;
|
|
26922
27007
|
for (const chunk of chunks) {
|
|
@@ -26946,7 +27031,7 @@ function timestampExtra(modified) {
|
|
|
26946
27031
|
view.setInt32(5, seconds, true);
|
|
26947
27032
|
return bytes3;
|
|
26948
27033
|
}
|
|
26949
|
-
async function writeZipArchive(archive, limits, signal) {
|
|
27034
|
+
async function writeZipArchive(archive, limits, signal, descriptors = false) {
|
|
26950
27035
|
const chunkSize2 = admit(limits, signal);
|
|
26951
27036
|
number3(archive.entries.length, Math.min(limits.maxMembers, 65534), "member");
|
|
26952
27037
|
number3(archive.comment.length, Math.min(limits.maxTextBytes, 65535), "archive comment");
|
|
@@ -26961,12 +27046,17 @@ async function writeZipArchive(archive, limits, signal) {
|
|
|
26961
27046
|
total += entry.size;
|
|
26962
27047
|
number3(total, limits.maxTotalBytes, "total byte");
|
|
26963
27048
|
const rawName = entry.rawName ?? pathBytes(entry.name, limits);
|
|
26964
|
-
const
|
|
27049
|
+
const descriptor = descriptors && !entry.directory;
|
|
27050
|
+
const flags3 = (entry.flags ?? 2048) & ~8 | (descriptor ? 8 : 0);
|
|
26965
27051
|
const comment2 = entry.comment ?? new Uint8Array();
|
|
26966
27052
|
number3(comment2.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
|
|
26967
27053
|
if (flags3 & 2048) text2(comment2);
|
|
26968
|
-
const
|
|
26969
|
-
|
|
27054
|
+
const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
|
|
27055
|
+
extras(originalLocalExtra, rawName, comment2, false, limits);
|
|
27056
|
+
const localExtra = stripZip64(originalLocalExtra);
|
|
27057
|
+
const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
|
|
27058
|
+
extras(originalCentralExtra, rawName, comment2, true, limits);
|
|
27059
|
+
const centralExtra = stripZip64(originalCentralExtra);
|
|
26970
27060
|
const localMetadata = extras(localExtra, rawName, comment2, false, limits);
|
|
26971
27061
|
const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
|
|
26972
27062
|
if (nameFrom(rawName, flags3, centralMetadata, limits) !== entry.name || localMetadata.name !== void 0 && nameFrom(rawName, flags3, localMetadata, limits) !== entry.name || entry.localName && !equal(rawName, entry.localName)) fail("ZIP retained filename metadata mismatch");
|
|
@@ -26989,8 +27079,8 @@ async function writeZipArchive(archive, limits, signal) {
|
|
|
26989
27079
|
if (mode !== entry.mode || Boolean(entry.externalAttributes & 16) && !entry.directory) fail("ZIP retained file attributes mismatch");
|
|
26990
27080
|
}
|
|
26991
27081
|
encoded2.push({ entry, rawName, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset: localLength });
|
|
26992
|
-
localLength += 30 + rawName.length + localExtra.length + entry.data.length;
|
|
26993
|
-
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length;
|
|
27082
|
+
localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? 16 : 0);
|
|
27083
|
+
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length + (descriptor ? 16 : 0);
|
|
26994
27084
|
number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
|
|
26995
27085
|
}
|
|
26996
27086
|
number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
|
|
@@ -27000,21 +27090,28 @@ async function writeZipArchive(archive, limits, signal) {
|
|
|
27000
27090
|
for (const item of encoded2) {
|
|
27001
27091
|
await yieldTurn(signal);
|
|
27002
27092
|
const { entry, rawName, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset } = item;
|
|
27003
|
-
const version = entry.method === 8 ? 20 : 10;
|
|
27093
|
+
const version = entry.method === 8 || flags3 & 8 ? 20 : 10;
|
|
27004
27094
|
view.setUint32(offset, 67324752, true);
|
|
27005
27095
|
view.setUint16(offset + 4, version, true);
|
|
27006
27096
|
view.setUint16(offset + 6, flags3, true);
|
|
27007
27097
|
view.setUint16(offset + 8, entry.method, true);
|
|
27008
27098
|
view.setUint16(offset + 10, time, true);
|
|
27009
27099
|
view.setUint16(offset + 12, date2, true);
|
|
27010
|
-
view.setUint32(offset + 14, entry.crc32, true);
|
|
27011
|
-
view.setUint32(offset + 18, entry.data.length, true);
|
|
27012
|
-
view.setUint32(offset + 22, entry.size, true);
|
|
27100
|
+
view.setUint32(offset + 14, flags3 & 8 ? 0 : entry.crc32, true);
|
|
27101
|
+
view.setUint32(offset + 18, flags3 & 8 ? 0 : entry.data.length, true);
|
|
27102
|
+
view.setUint32(offset + 22, flags3 & 8 ? 0 : entry.size, true);
|
|
27013
27103
|
view.setUint16(offset + 26, rawName.length, true);
|
|
27014
27104
|
view.setUint16(offset + 28, localExtra.length, true);
|
|
27015
27105
|
bytes3.set(rawName, offset + 30);
|
|
27016
27106
|
bytes3.set(localExtra, offset + 30 + rawName.length);
|
|
27017
27107
|
await copyBytes(entry.data, bytes3, offset + 30 + rawName.length + localExtra.length, chunkSize2, signal);
|
|
27108
|
+
if (flags3 & 8) {
|
|
27109
|
+
const descriptor = offset + 30 + rawName.length + localExtra.length + entry.data.length;
|
|
27110
|
+
view.setUint32(descriptor, 134695760, true);
|
|
27111
|
+
view.setUint32(descriptor + 4, entry.crc32, true);
|
|
27112
|
+
view.setUint32(descriptor + 8, entry.data.length, true);
|
|
27113
|
+
view.setUint32(descriptor + 12, entry.size, true);
|
|
27114
|
+
}
|
|
27018
27115
|
view.setUint32(central, 33639248, true);
|
|
27019
27116
|
view.setUint16(central + 4, entry.versionMadeBy ?? 798, true);
|
|
27020
27117
|
view.setUint16(central + 6, version, true);
|
|
@@ -27029,7 +27126,8 @@ async function writeZipArchive(archive, limits, signal) {
|
|
|
27029
27126
|
view.setUint16(central + 30, centralExtra.length, true);
|
|
27030
27127
|
view.setUint16(central + 32, comment2.length, true);
|
|
27031
27128
|
view.setUint16(central + 36, entry.internalAttributes ?? 0, true);
|
|
27032
|
-
|
|
27129
|
+
const mode = entry.mode & 61440 ? entry.mode : entry.mode | (entry.directory ? 16384 : entry.symlink ? 40960 : 32768);
|
|
27130
|
+
view.setUint32(central + 38, entry.externalAttributes ?? mode * 65536 + (entry.directory ? 16 : 0), true);
|
|
27033
27131
|
view.setUint32(central + 42, offset, true);
|
|
27034
27132
|
bytes3.set(rawName, central + 46);
|
|
27035
27133
|
bytes3.set(centralExtra, central + 46 + rawName.length);
|
|
@@ -27066,6 +27164,7 @@ var ZipScope = class {
|
|
|
27066
27164
|
closedReason = new Error("ZIP command is closed");
|
|
27067
27165
|
drain;
|
|
27068
27166
|
work = 0;
|
|
27167
|
+
stdinSource;
|
|
27069
27168
|
close = () => {
|
|
27070
27169
|
if (!this.drain) {
|
|
27071
27170
|
this.drain = Promise.resolve().then(async () => {
|
|
@@ -27104,6 +27203,9 @@ var ZipScope = class {
|
|
|
27104
27203
|
throw error;
|
|
27105
27204
|
}
|
|
27106
27205
|
}
|
|
27206
|
+
get stdin() {
|
|
27207
|
+
return this.stdinSource ??= this.source(this.original.stdin);
|
|
27208
|
+
}
|
|
27107
27209
|
source(source2) {
|
|
27108
27210
|
const iterator = source2[Symbol.asyncIterator]();
|
|
27109
27211
|
let closing;
|
|
@@ -27602,13 +27704,16 @@ async function parse12(scope, limits) {
|
|
|
27602
27704
|
operands.push(argument2);
|
|
27603
27705
|
}
|
|
27604
27706
|
}
|
|
27605
|
-
if (archive === void 0)
|
|
27606
|
-
|
|
27607
|
-
|
|
27707
|
+
if (archive === void 0) {
|
|
27708
|
+
if (action !== "add") throw new ZipFailure(16, "Invalid command arguments", "expected archive name");
|
|
27709
|
+
archive = "-";
|
|
27710
|
+
if (!stdinNames) operands.push("-");
|
|
27711
|
+
}
|
|
27712
|
+
if (archive !== "-" && !archive.slice(archive.lastIndexOf("/") + 1).includes(".")) archive += ".zip";
|
|
27608
27713
|
checkPath(archive, limits);
|
|
27609
27714
|
const names = [];
|
|
27610
27715
|
if (stdinNames) {
|
|
27611
|
-
const input3 = await collectBytes(scope.
|
|
27716
|
+
const input3 = await collectBytes(scope.stdin, { maxBytes: limits.maxFilesFromBytes, signal: context2.signal });
|
|
27612
27717
|
let start = 0;
|
|
27613
27718
|
let lines3 = 0;
|
|
27614
27719
|
for (let end = 0; end <= input3.length; end++) {
|
|
@@ -27669,21 +27774,29 @@ async function filterName(name2, selection, includeCount) {
|
|
|
27669
27774
|
async function prepare(scope, parsed, budget) {
|
|
27670
27775
|
const context2 = scope.context;
|
|
27671
27776
|
const limits = budget.limits;
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
|
|
27678
|
-
|
|
27777
|
+
if (parsed.archive === "-" && parsed.action !== "add") throw new ZipFailure(16, "Invalid command arguments", "can't use -d, -f, -u, -U, or -g on stdout\n");
|
|
27778
|
+
let publication;
|
|
27779
|
+
if (parsed.archive !== "-") {
|
|
27780
|
+
const outputName = vfsPath(context2.cwd, parsed.archive);
|
|
27781
|
+
const parentName = dirname(outputName);
|
|
27782
|
+
const parent = await scope.operation(() => context2.fs.realpath(parentName, { signal: context2.signal }));
|
|
27783
|
+
const parentStat = await scope.operation(() => context2.fs.lstat(parent, { signal: context2.signal }));
|
|
27784
|
+
const output3 = `${parent === "/" ? "" : parent}/${outputName.slice(outputName.lastIndexOf("/") + 1)}`;
|
|
27785
|
+
checkPath(output3, limits);
|
|
27786
|
+
const existing3 = await scope.stat(output3);
|
|
27787
|
+
publication = { output: output3, parentName, parent, parentStat, existing: existing3 };
|
|
27788
|
+
}
|
|
27789
|
+
const output2 = publication?.output;
|
|
27790
|
+
const existing2 = publication?.existing;
|
|
27791
|
+
if (parsed.archive === "-" && parsed.test && !parsed.quiet) await budget.output(" zip warning: can't use -T on stdout, -T ignored\n");
|
|
27679
27792
|
if (existing2 && (existing2.type !== "file" || !hasIdentity(existing2) || existing2.nlink !== 1)) fail("updating archive requires a regular, single-link file with known backing identity; archive aliases are unsupported");
|
|
27680
27793
|
let archive = { entries: [], comment: new Uint8Array() };
|
|
27681
|
-
if (existing2) {
|
|
27794
|
+
if (existing2 && publication) {
|
|
27682
27795
|
if (!Number.isSafeInteger(existing2.size) || existing2.size < 0 || existing2.size > limits.maxArchiveBytes) fail("archive byte limit exceeded");
|
|
27683
|
-
const bytes4 = await collectBytes(scope.input(
|
|
27796
|
+
const bytes4 = await collectBytes(scope.input(publication.output), { maxBytes: limits.maxArchiveBytes, signal: context2.signal });
|
|
27684
27797
|
if (bytes4.length !== existing2.size) fail("archive changed while reading");
|
|
27685
27798
|
archive = await readZipArchive(bytes4, limits, context2.signal);
|
|
27686
|
-
const current = await scope.stat(
|
|
27799
|
+
const current = await scope.stat(publication.output);
|
|
27687
27800
|
if (!current || !unchanged4(existing2, current)) fail("archive changed while reading");
|
|
27688
27801
|
}
|
|
27689
27802
|
const old = new Map(archive.entries.map((entry) => [entry.name, entry]));
|
|
@@ -27696,12 +27809,35 @@ async function prepare(scope, parsed, budget) {
|
|
|
27696
27809
|
let visits = 0;
|
|
27697
27810
|
let work = 0;
|
|
27698
27811
|
let compressedBytes = 0;
|
|
27812
|
+
const encodeSelected = async (source2, name2, bytes4, attributes) => {
|
|
27813
|
+
const store = parsed.method === "store" || parsed.level !== 9 && parsed.suffixes.some((suffix2) => name2.endsWith(suffix2));
|
|
27814
|
+
if (!store && parsed.level === 0 && bytes4.length && !attributes.directory && !attributes.symlink) throw new ZipFailure(5, "Internal logic error", "bad pack level");
|
|
27815
|
+
const level = store ? 0 : parsed.level;
|
|
27816
|
+
let entry = await makeZipEntry(name2, bytes4, attributes, limits, context2.signal, level, parsed.archive === "-" && !store);
|
|
27817
|
+
const prior = old.get(name2);
|
|
27818
|
+
if (prior?.comment) entry = { ...entry, comment: prior.comment };
|
|
27819
|
+
if (entry.data.length > limits.maxArchiveBytes - compressedBytes) fail("archive byte limit exceeded");
|
|
27820
|
+
compressedBytes += entry.data.length;
|
|
27821
|
+
selected.set(name2, { entry, source: source2 });
|
|
27822
|
+
};
|
|
27699
27823
|
const visit = async (source2, name2, depth) => {
|
|
27700
27824
|
context2.signal.throwIfAborted();
|
|
27701
27825
|
if (++visits > limits.maxMembers) fail("traversal member limit exceeded");
|
|
27702
27826
|
if (++work > limits.maxPatternSteps) fail("archive work limit exceeded");
|
|
27703
27827
|
if (visits % 128 === 0) await yieldTurn(context2.signal);
|
|
27704
27828
|
if (depth > limits.maxDepth) fail("archive recursion depth limit exceeded");
|
|
27829
|
+
if (source2 === "-") {
|
|
27830
|
+
const previous = selected.get(name2);
|
|
27831
|
+
if (previous && previous.source !== source2) throw new ZipFailure(16, "Invalid command arguments", "cannot repeat names in zip file");
|
|
27832
|
+
if (previous || !await filterName(name2, selection, parsed.includes.length)) return;
|
|
27833
|
+
const prior2 = old.get(name2);
|
|
27834
|
+
const modified = /* @__PURE__ */ new Date();
|
|
27835
|
+
if (parsed.action === "freshen" && !prior2 || prior2 && (parsed.action === "update" || parsed.action === "freshen") && Math.floor(modified.getTime() / 1e3) <= Math.floor(prior2.modified.getTime() / 1e3)) return;
|
|
27836
|
+
const bytes4 = await collectBytes(scope.stdin, { maxBytes: Math.min(limits.maxEntryBytes, limits.maxTotalBytes - budget.totalBytes), signal: context2.signal });
|
|
27837
|
+
await budget.member(bytes4.length);
|
|
27838
|
+
await encodeSelected(source2, name2, bytes4, { modified, mode: 4528, directory: false, symlink: false });
|
|
27839
|
+
return;
|
|
27840
|
+
}
|
|
27705
27841
|
const path = vfsPath(context2.cwd, source2);
|
|
27706
27842
|
checkPath(path, limits);
|
|
27707
27843
|
let canonical;
|
|
@@ -27754,14 +27890,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27754
27890
|
if (!directory2 && bytes4.length !== stat.size) fail(`source changed while reading: ${source2}`);
|
|
27755
27891
|
const current = await inspectSource(scope, path, parsed.storeLinks);
|
|
27756
27892
|
if (current.canonical !== canonical || !unchanged4(stat, current.stat)) fail(`source changed while reading: ${source2}`);
|
|
27757
|
-
|
|
27758
|
-
if (!store && parsed.level === 0 && stat.size && !directory2 && !symlink) throw new ZipFailure(5, "Internal logic error", "bad pack level");
|
|
27759
|
-
const level = store ? 0 : parsed.level;
|
|
27760
|
-
let entry = await makeZipEntry(name2, bytes4, { modified: new Date(stat.mtimeMs), mode: stat.mode, directory: directory2, symlink }, limits, context2.signal, level);
|
|
27761
|
-
if (prior?.comment) entry = { ...entry, comment: prior.comment };
|
|
27762
|
-
if (entry.data.length > limits.maxArchiveBytes - compressedBytes) fail("archive byte limit exceeded");
|
|
27763
|
-
compressedBytes += entry.data.length;
|
|
27764
|
-
selected.set(name2, { entry, source: source2 });
|
|
27893
|
+
await encodeSelected(source2, name2, bytes4, { modified: new Date(stat.mtimeMs), mode: stat.mode, directory: directory2, symlink });
|
|
27765
27894
|
}
|
|
27766
27895
|
}
|
|
27767
27896
|
if (directory2 && parsed.recursive) {
|
|
@@ -27842,8 +27971,8 @@ async function prepare(scope, parsed, budget) {
|
|
|
27842
27971
|
append(entry, false);
|
|
27843
27972
|
}
|
|
27844
27973
|
if (!entries2.length) queue(" zip warning: zip file empty\n");
|
|
27845
|
-
const bytes3 = await writeZipArchive({ entries: entries2, comment: archive.comment }, limits, context2.signal);
|
|
27846
|
-
if (parsed.test) {
|
|
27974
|
+
const bytes3 = await writeZipArchive({ entries: entries2, comment: archive.comment }, limits, context2.signal, parsed.archive === "-");
|
|
27975
|
+
if (parsed.test && parsed.archive !== "-") {
|
|
27847
27976
|
for (const message3 of progress) await budget.output(message3);
|
|
27848
27977
|
progress.length = 0;
|
|
27849
27978
|
progressBytes = 0;
|
|
@@ -27868,7 +27997,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27868
27997
|
`);
|
|
27869
27998
|
}
|
|
27870
27999
|
}
|
|
27871
|
-
return {
|
|
28000
|
+
return { publication, bytes: bytes3, progress };
|
|
27872
28001
|
}
|
|
27873
28002
|
function createZipCommand(options2 = {}) {
|
|
27874
28003
|
const limits = settings2(options2);
|
|
@@ -27876,13 +28005,25 @@ function createZipCommand(options2 = {}) {
|
|
|
27876
28005
|
original.signal.throwIfAborted();
|
|
27877
28006
|
const scope = new ZipScope(original, limits);
|
|
27878
28007
|
const context2 = scope.context;
|
|
27879
|
-
|
|
28008
|
+
let budget = new Budget14(context2, limits);
|
|
27880
28009
|
try {
|
|
27881
28010
|
const parsed = await parse12(scope, limits);
|
|
28011
|
+
if (parsed.archive === "-") budget = new Budget14({ ...context2, stdout: context2.stderr }, limits);
|
|
27882
28012
|
const prepared = await prepare(scope, parsed, budget);
|
|
27883
28013
|
if (!prepared) return { exitCode: 12 };
|
|
27884
|
-
|
|
27885
|
-
|
|
28014
|
+
const publication = prepared.publication;
|
|
28015
|
+
if (publication) {
|
|
28016
|
+
await writeFileOutput(context2, prepared.bytes, () => scope.operation(() => publishZip(scope, { ...publication, bytes: prepared.bytes })));
|
|
28017
|
+
for (const message3 of prepared.progress) await budget.output(message3);
|
|
28018
|
+
} else {
|
|
28019
|
+
for (const message3 of prepared.progress) await budget.output(message3);
|
|
28020
|
+
const output2 = createOutputOperation(context2, context2.stdout);
|
|
28021
|
+
try {
|
|
28022
|
+
await writeBytes(output2.output, prepared.bytes, output2.signal);
|
|
28023
|
+
} finally {
|
|
28024
|
+
await output2.close();
|
|
28025
|
+
}
|
|
28026
|
+
}
|
|
27886
28027
|
return { exitCode: 0 };
|
|
27887
28028
|
} catch (error) {
|
|
27888
28029
|
original.signal.throwIfAborted();
|
|
@@ -28288,7 +28429,7 @@ function createUnzipCommand(options2 = {}) {
|
|
|
28288
28429
|
}
|
|
28289
28430
|
let path = extraction.member(root, entry.name);
|
|
28290
28431
|
const fileType = entry.mode & 61440;
|
|
28291
|
-
if (fileType && fileType !== 32768 && fileType !== 16384 && fileType !== 40960) fail("unsupported special ZIP entry");
|
|
28432
|
+
if (fileType && fileType !== 32768 && fileType !== 16384 && fileType !== 40960 && fileType !== 4096) fail("unsupported special ZIP entry");
|
|
28292
28433
|
if (path === root && !entry.directory) fail("entry would replace extraction root");
|
|
28293
28434
|
let shown = parsed.destination === void 0 ? entry.name : `${parsed.destination.endsWith("/") ? parsed.destination : `${parsed.destination}/`}${entry.name}`;
|
|
28294
28435
|
await extraction.parents(root, path, true);
|