@poe-platform/safe-bash 0.1.616 → 0.1.618
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/zip/options.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip/options.js +9 -5
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts +12 -0
- package/dist/safe-bash/commands/archive/zip/zip64.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js +118 -0
- package/dist/safe-bash/commands/archive/zip/zip64.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip-format.d.ts +4 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.js +133 -59
- 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 +28 -7
- 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 +289 -98
- 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
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
createLineEndingCommands,
|
|
35
35
|
createUnix2dosCommand,
|
|
36
36
|
lineEndingCommands
|
|
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,106 @@ 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
|
+
function zip64Extra(values, retained) {
|
|
26692
|
+
if (retained.length + 4 + values.length * 8 > 65535) fail("ZIP64 extra field limit exceeded");
|
|
26693
|
+
const bytes3 = new Uint8Array(4 + values.length * 8 + retained.length);
|
|
26694
|
+
const view = new DataView(bytes3.buffer);
|
|
26695
|
+
view.setUint16(0, 1, true);
|
|
26696
|
+
view.setUint16(2, values.length * 8, true);
|
|
26697
|
+
values.forEach((value2, index) => view.setBigUint64(4 + index * 8, BigInt(value2), true));
|
|
26698
|
+
bytes3.set(retained, 4 + values.length * 8);
|
|
26699
|
+
return bytes3;
|
|
26700
|
+
}
|
|
26701
|
+
function writeZip64End(view, offset, count2, size, start, recordOffset = offset) {
|
|
26702
|
+
view.setUint32(offset, 101075792, true);
|
|
26703
|
+
view.setBigUint64(offset + 4, 44n, true);
|
|
26704
|
+
view.setUint16(offset + 12, 813, true);
|
|
26705
|
+
view.setUint16(offset + 14, 45, true);
|
|
26706
|
+
view.setBigUint64(offset + 24, BigInt(count2), true);
|
|
26707
|
+
view.setBigUint64(offset + 32, BigInt(count2), true);
|
|
26708
|
+
view.setBigUint64(offset + 40, BigInt(size), true);
|
|
26709
|
+
view.setBigUint64(offset + 48, BigInt(start), true);
|
|
26710
|
+
view.setUint32(offset + 56, 117853008, true);
|
|
26711
|
+
view.setBigUint64(offset + 64, BigInt(recordOffset), true);
|
|
26712
|
+
view.setUint32(offset + 72, 1, true);
|
|
26713
|
+
return offset + 76;
|
|
26714
|
+
}
|
|
26715
|
+
|
|
26716
|
+
// packages/safe-bash/src/commands/archive/zip-format.ts
|
|
26617
26717
|
var encoder2 = new TextEncoder();
|
|
26618
26718
|
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
26719
|
var crcTable4 = Uint32Array.from({ length: 256 }, (_, index) => {
|
|
@@ -26670,7 +26770,10 @@ function extras(bytes3, rawName, comment2, central, limits) {
|
|
|
26670
26770
|
if (offset + length > bytes3.length) fail("ZIP truncated extra field payload");
|
|
26671
26771
|
if (seen.has(identifier)) fail("ZIP duplicate extra field");
|
|
26672
26772
|
seen.add(identifier);
|
|
26673
|
-
if (identifier === 1)
|
|
26773
|
+
if (identifier === 1) {
|
|
26774
|
+
if (!length || length > 28 || length % 4) fail("ZIP64 invalid extra field length");
|
|
26775
|
+
result.zip64 = bytes3.subarray(offset, offset + length);
|
|
26776
|
+
}
|
|
26674
26777
|
if (identifier === 39169 || identifier === 23 || identifier === 24 || identifier === 25) fail("ZIP encryption is unsupported");
|
|
26675
26778
|
if (identifier === 28789 || identifier === 25461) {
|
|
26676
26779
|
if (length < 5 || bytes3[offset] !== 1) fail("ZIP unsupported or truncated Unicode extra field");
|
|
@@ -26706,7 +26809,7 @@ function format(method, flags3, version) {
|
|
|
26706
26809
|
if (flags3 & (1 | 64 | 8192)) fail("ZIP encryption is unsupported");
|
|
26707
26810
|
if (flags3 & ~2062 || method === 0 && flags3 & 6) fail("ZIP unsupported general purpose flags");
|
|
26708
26811
|
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)");
|
|
26812
|
+
if (version < (method === 8 || flags3 & 8 ? 20 : 10) || version > 20 && version !== 45) fail("ZIP unsupported extraction version (including ZIP64)");
|
|
26710
26813
|
}
|
|
26711
26814
|
function dosModified(date2, time) {
|
|
26712
26815
|
if (!date2 && !time) return new Date(1980, 0, 1);
|
|
@@ -26758,13 +26861,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26758
26861
|
}
|
|
26759
26862
|
}
|
|
26760
26863
|
if (end === -1) fail("ZIP truncated or missing end of central directory");
|
|
26761
|
-
const members = view
|
|
26762
|
-
const centralSize = view.getUint32(end + 12, true);
|
|
26763
|
-
const centralStart = view.getUint32(end + 16, true);
|
|
26764
|
-
if (members === 65535 || centralSize === 4294967295 || centralStart === 4294967295) fail("ZIP64 is unsupported");
|
|
26765
|
-
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");
|
|
26766
|
-
if (centralStart + centralSize !== end) fail("ZIP invalid central directory span or unsupported ZIP64/trailing records");
|
|
26767
|
-
number3(members, limits.maxMembers, "member");
|
|
26864
|
+
const { members, centralStart, centralEnd } = zip64Directory(view, end, limits);
|
|
26768
26865
|
number3(bytes3.length - end - 22, limits.maxTextBytes, "archive comment");
|
|
26769
26866
|
const entries2 = [];
|
|
26770
26867
|
const spans = [];
|
|
@@ -26772,7 +26869,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26772
26869
|
let total = 0;
|
|
26773
26870
|
for (let index = 0; index < members; index++) {
|
|
26774
26871
|
await yieldTurn(signal);
|
|
26775
|
-
if (offset + 46 >
|
|
26872
|
+
if (offset + 46 > centralEnd || view.getUint32(offset, true) !== 33639248) fail("ZIP truncated or invalid central header");
|
|
26776
26873
|
const versionMadeBy = view.getUint16(offset + 4, true);
|
|
26777
26874
|
const version = view.getUint16(offset + 6, true);
|
|
26778
26875
|
const flags3 = view.getUint16(offset + 8, true);
|
|
@@ -26781,29 +26878,32 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26781
26878
|
const dosTime = view.getUint16(offset + 12, true);
|
|
26782
26879
|
const dosDate = view.getUint16(offset + 14, true);
|
|
26783
26880
|
const checksum = view.getUint32(offset + 16, true);
|
|
26784
|
-
|
|
26785
|
-
|
|
26881
|
+
let compressedSize = view.getUint32(offset + 20, true);
|
|
26882
|
+
let size = view.getUint32(offset + 24, true);
|
|
26786
26883
|
const nameLength = view.getUint16(offset + 28, true);
|
|
26787
26884
|
const extraLength = view.getUint16(offset + 30, true);
|
|
26788
26885
|
const commentLength = view.getUint16(offset + 32, true);
|
|
26789
26886
|
const internalAttributes = view.getUint16(offset + 36, true);
|
|
26790
26887
|
if (internalAttributes & ~1) fail("ZIP unsupported internal attributes");
|
|
26791
26888
|
const externalAttributes = view.getUint32(offset + 38, true);
|
|
26792
|
-
|
|
26793
|
-
|
|
26794
|
-
if (compressedSize === 4294967295 || size === 4294967295 || local === 4294967295) fail("ZIP64 is unsupported");
|
|
26795
|
-
number3(size, limits.maxEntryBytes, "entry byte");
|
|
26796
|
-
if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
|
|
26797
|
-
total += size;
|
|
26798
|
-
number3(total, limits.maxTotalBytes, "total byte");
|
|
26889
|
+
let local = view.getUint32(offset + 42, true);
|
|
26890
|
+
const disk = view.getUint16(offset + 34, true);
|
|
26799
26891
|
const next = offset + 46 + nameLength + extraLength + commentLength;
|
|
26800
|
-
if (next >
|
|
26892
|
+
if (next > centralEnd) fail("ZIP truncated central metadata");
|
|
26801
26893
|
number3(commentLength, limits.maxTextBytes, "entry comment");
|
|
26802
26894
|
const rawName = bytes3.subarray(offset + 46, offset + 46 + nameLength);
|
|
26803
26895
|
const centralExtra = bytes3.subarray(offset + 46 + nameLength, next - commentLength);
|
|
26804
26896
|
const comment2 = bytes3.subarray(next - commentLength, next);
|
|
26805
26897
|
if (flags3 & 2048) text2(comment2);
|
|
26806
26898
|
const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
|
|
26899
|
+
const resolved = zip64Fields(centralMetadata.zip64, [size, compressedSize, local, disk === 65535 ? 4294967295 : disk]);
|
|
26900
|
+
[size, compressedSize, local] = resolved;
|
|
26901
|
+
if (resolved[3]) fail("ZIP multi-disk member is unsupported");
|
|
26902
|
+
number3(size, limits.maxEntryBytes, "entry byte");
|
|
26903
|
+
number3(compressedSize, limits.maxArchiveBytes, "compressed entry byte");
|
|
26904
|
+
if (method === 0 && compressedSize !== size) fail("ZIP stored size mismatch");
|
|
26905
|
+
total += size;
|
|
26906
|
+
number3(total, limits.maxTotalBytes, "total byte");
|
|
26807
26907
|
const name2 = nameFrom(rawName, flags3, centralMetadata, limits);
|
|
26808
26908
|
if (local + 30 > centralStart || view.getUint32(local, true) !== 67324752) fail("ZIP invalid local header span");
|
|
26809
26909
|
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");
|
|
@@ -26819,15 +26919,22 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26819
26919
|
const localEffective = nameFrom(localName, flags3, localMetadata, limits);
|
|
26820
26920
|
if (localMetadata.name !== void 0 && localEffective !== name2) fail("ZIP central/local Unicode name mismatch");
|
|
26821
26921
|
if (centralMetadata.modified !== void 0 && localMetadata.modified !== void 0 && centralMetadata.modified !== localMetadata.modified) fail("ZIP central/local timestamp mismatch");
|
|
26822
|
-
|
|
26823
|
-
|
|
26922
|
+
const rawLocalSize = view.getUint32(local + 22, true);
|
|
26923
|
+
const rawLocalCompressed = view.getUint32(local + 18, true);
|
|
26924
|
+
const [localSize, localCompressed] = zip64Fields(localMetadata.zip64, [rawLocalSize, rawLocalCompressed]);
|
|
26925
|
+
for (const [actual, expected] of [[view.getUint32(local + 14, true), checksum], [localCompressed, compressedSize], [localSize, size]]) {
|
|
26824
26926
|
if (actual !== expected && (!(flags3 & 8) || actual !== 0)) fail("ZIP central/local size or CRC mismatch");
|
|
26825
26927
|
}
|
|
26826
26928
|
if (flags3 & 8) {
|
|
26827
26929
|
const matches2 = [];
|
|
26828
26930
|
for (const signed2 of [false, true]) {
|
|
26829
26931
|
const descriptor = payloadEnd + (signed2 ? 4 : 0);
|
|
26830
|
-
|
|
26932
|
+
const wide2 = rawLocalSize === 4294967295 || rawLocalCompressed === 4294967295;
|
|
26933
|
+
const length = wide2 ? 20 : 12;
|
|
26934
|
+
if (descriptor + length > centralStart || signed2 && view.getUint32(payloadEnd, true) !== 134695760 || view.getUint32(descriptor, true) !== checksum) continue;
|
|
26935
|
+
const compressed2 = wide2 ? view.getBigUint64(descriptor + 4, true) : BigInt(view.getUint32(descriptor + 4, true));
|
|
26936
|
+
const expanded = wide2 ? view.getBigUint64(descriptor + 12, true) : BigInt(view.getUint32(descriptor + 8, true));
|
|
26937
|
+
if (compressed2 === BigInt(compressedSize) && expanded === BigInt(size)) matches2.push(descriptor + length);
|
|
26831
26938
|
}
|
|
26832
26939
|
if (matches2.length !== 1) fail("ZIP truncated, ambiguous or mismatched data descriptor");
|
|
26833
26940
|
payloadEnd = matches2[0];
|
|
@@ -26847,7 +26954,7 @@ async function readZipArchive(bytes3, limits, signal) {
|
|
|
26847
26954
|
spans.push({ start: local, end: payloadEnd });
|
|
26848
26955
|
offset = next;
|
|
26849
26956
|
}
|
|
26850
|
-
if (offset !==
|
|
26957
|
+
if (offset !== centralEnd) fail("ZIP central directory size or member count mismatch");
|
|
26851
26958
|
spans.sort((first, second) => first.start - second.start);
|
|
26852
26959
|
let covered = 0;
|
|
26853
26960
|
for (const span of spans) {
|
|
@@ -26948,11 +27055,43 @@ function timestampExtra(modified) {
|
|
|
26948
27055
|
view.setInt32(5, seconds, true);
|
|
26949
27056
|
return bytes3;
|
|
26950
27057
|
}
|
|
26951
|
-
|
|
27058
|
+
function updateZipExtras(entry, previous, mode, limits) {
|
|
27059
|
+
const fresh = mode === "strip" ? new Uint8Array() : timestampExtra(entry.modified);
|
|
27060
|
+
const retained = [];
|
|
27061
|
+
for (const [original, central] of [[previous?.localExtra, false], [previous?.centralExtra, true]]) {
|
|
27062
|
+
const fields3 = [];
|
|
27063
|
+
let length = fresh.length;
|
|
27064
|
+
if (mode === "all" && original) {
|
|
27065
|
+
extras(original, previous.rawName ?? pathBytes(previous.name, limits), previous.comment ?? new Uint8Array(), central, limits);
|
|
27066
|
+
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
27067
|
+
for (let offset2 = 0; offset2 < original.length; ) {
|
|
27068
|
+
const identifier = view.getUint16(offset2, true);
|
|
27069
|
+
const next = offset2 + 4 + view.getUint16(offset2 + 2, true);
|
|
27070
|
+
if (identifier !== 1 && identifier !== 21589 && identifier !== 28789 && identifier !== 25461) {
|
|
27071
|
+
fields3.push(original.subarray(offset2, next));
|
|
27072
|
+
length += next - offset2;
|
|
27073
|
+
}
|
|
27074
|
+
offset2 = next;
|
|
27075
|
+
}
|
|
27076
|
+
}
|
|
27077
|
+
number3(length, Math.min(limits.maxPaxBytes, 65535), "extra field");
|
|
27078
|
+
const bytes3 = new Uint8Array(length);
|
|
27079
|
+
let offset = 0;
|
|
27080
|
+
for (const field2 of fields3) {
|
|
27081
|
+
bytes3.set(field2, offset);
|
|
27082
|
+
offset += field2.length;
|
|
27083
|
+
}
|
|
27084
|
+
bytes3.set(fresh, offset);
|
|
27085
|
+
retained.push(bytes3);
|
|
27086
|
+
}
|
|
27087
|
+
return { ...entry, localExtra: retained[0], centralExtra: retained[1] };
|
|
27088
|
+
}
|
|
27089
|
+
async function* streamZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
|
|
26952
27090
|
const chunkSize2 = admit(limits, signal);
|
|
26953
27091
|
number3(archive.entries.length, Math.min(limits.maxMembers, 65534), "member");
|
|
26954
27092
|
number3(archive.comment.length, Math.min(limits.maxTextBytes, 65535), "archive comment");
|
|
26955
|
-
|
|
27093
|
+
const wideArchive = forceZip64 || archive.entries.some((entry) => entry.zip64);
|
|
27094
|
+
let length = 22 + archive.comment.length + (wideArchive ? 76 : 0);
|
|
26956
27095
|
let localLength = 0;
|
|
26957
27096
|
let total = 0;
|
|
26958
27097
|
const encoded2 = [];
|
|
@@ -26968,8 +27107,13 @@ async function writeZipArchive(archive, limits, signal, descriptors = false) {
|
|
|
26968
27107
|
const comment2 = entry.comment ?? new Uint8Array();
|
|
26969
27108
|
number3(comment2.length, Math.min(limits.maxTextBytes, 65535), "entry comment");
|
|
26970
27109
|
if (flags3 & 2048) text2(comment2);
|
|
26971
|
-
const
|
|
26972
|
-
|
|
27110
|
+
const originalLocalExtra = entry.localExtra ?? timestampExtra(entry.modified);
|
|
27111
|
+
extras(originalLocalExtra, rawName, comment2, false, limits);
|
|
27112
|
+
const wide2 = forceZip64 || entry.zip64 === true;
|
|
27113
|
+
const localExtra = wide2 ? zip64Extra([descriptor ? 0 : entry.size, descriptor ? 0 : entry.data.length], stripZip64(originalLocalExtra)) : stripZip64(originalLocalExtra);
|
|
27114
|
+
const originalCentralExtra = entry.centralExtra ?? timestampExtra(entry.modified);
|
|
27115
|
+
extras(originalCentralExtra, rawName, comment2, true, limits);
|
|
27116
|
+
const centralExtra = wide2 ? zip64Extra([entry.size, entry.data.length, localLength], stripZip64(originalCentralExtra)) : stripZip64(originalCentralExtra);
|
|
26973
27117
|
const localMetadata = extras(localExtra, rawName, comment2, false, limits);
|
|
26974
27118
|
const centralMetadata = extras(centralExtra, rawName, comment2, true, limits);
|
|
26975
27119
|
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");
|
|
@@ -26991,71 +27135,101 @@ async function writeZipArchive(archive, limits, signal, descriptors = false) {
|
|
|
26991
27135
|
const mode = unixMode || (entry.directory ? 16877 : 33188);
|
|
26992
27136
|
if (mode !== entry.mode || Boolean(entry.externalAttributes & 16) && !entry.directory) fail("ZIP retained file attributes mismatch");
|
|
26993
27137
|
}
|
|
26994
|
-
encoded2.push({ entry, rawName, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset: localLength });
|
|
26995
|
-
localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? 16 : 0);
|
|
26996
|
-
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length + (descriptor ? 16 : 0);
|
|
27138
|
+
encoded2.push({ entry, rawName, wide: wide2, flags: flags3, localExtra, centralExtra, comment: comment2, date: date2, time, offset: localLength });
|
|
27139
|
+
localLength += 30 + rawName.length + localExtra.length + entry.data.length + (descriptor ? wide2 ? 24 : 16 : 0);
|
|
27140
|
+
length += 76 + 2 * rawName.length + localExtra.length + centralExtra.length + comment2.length + entry.data.length + (descriptor ? wide2 ? 24 : 16 : 0);
|
|
26997
27141
|
number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
|
|
26998
27142
|
}
|
|
26999
27143
|
number3(length, Math.min(limits.maxArchiveBytes, 4294967294), "archive byte");
|
|
27000
|
-
const bytes3 = new Uint8Array(length);
|
|
27001
|
-
const view = new DataView(bytes3.buffer);
|
|
27002
|
-
let central = localLength;
|
|
27003
27144
|
for (const item of encoded2) {
|
|
27004
27145
|
await yieldTurn(signal);
|
|
27005
|
-
const { entry, rawName, flags: flags3, localExtra,
|
|
27006
|
-
const
|
|
27007
|
-
|
|
27008
|
-
|
|
27009
|
-
|
|
27010
|
-
|
|
27011
|
-
|
|
27012
|
-
|
|
27013
|
-
|
|
27014
|
-
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
|
|
27020
|
-
|
|
27146
|
+
const { entry, rawName, wide: wide2, flags: flags3, localExtra, date: date2, time } = item;
|
|
27147
|
+
const offset = 0;
|
|
27148
|
+
const bytes4 = new Uint8Array(30 + rawName.length + localExtra.length);
|
|
27149
|
+
const view2 = new DataView(bytes4.buffer);
|
|
27150
|
+
const version = wide2 ? 45 : entry.method === 8 || flags3 & 8 ? 20 : 10;
|
|
27151
|
+
view2.setUint32(offset, 67324752, true);
|
|
27152
|
+
view2.setUint16(offset + 4, version, true);
|
|
27153
|
+
view2.setUint16(offset + 6, flags3, true);
|
|
27154
|
+
view2.setUint16(offset + 8, entry.method, true);
|
|
27155
|
+
view2.setUint16(offset + 10, time, true);
|
|
27156
|
+
view2.setUint16(offset + 12, date2, true);
|
|
27157
|
+
view2.setUint32(offset + 14, flags3 & 8 ? 0 : entry.crc32, true);
|
|
27158
|
+
view2.setUint32(offset + 18, wide2 ? 4294967295 : flags3 & 8 ? 0 : entry.data.length, true);
|
|
27159
|
+
view2.setUint32(offset + 22, wide2 ? 4294967295 : flags3 & 8 ? 0 : entry.size, true);
|
|
27160
|
+
view2.setUint16(offset + 26, rawName.length, true);
|
|
27161
|
+
view2.setUint16(offset + 28, localExtra.length, true);
|
|
27162
|
+
bytes4.set(rawName, offset + 30);
|
|
27163
|
+
bytes4.set(localExtra, offset + 30 + rawName.length);
|
|
27164
|
+
yield* wireChunks(bytes4, chunkSize2, signal);
|
|
27165
|
+
yield* wireChunks(entry.data, chunkSize2, signal);
|
|
27021
27166
|
if (flags3 & 8) {
|
|
27022
|
-
const descriptor =
|
|
27023
|
-
|
|
27024
|
-
|
|
27025
|
-
|
|
27026
|
-
|
|
27027
|
-
|
|
27028
|
-
|
|
27029
|
-
|
|
27030
|
-
|
|
27031
|
-
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
view.setUint32(central + 20, entry.data.length, true);
|
|
27037
|
-
view.setUint32(central + 24, entry.size, true);
|
|
27038
|
-
view.setUint16(central + 28, rawName.length, true);
|
|
27039
|
-
view.setUint16(central + 30, centralExtra.length, true);
|
|
27040
|
-
view.setUint16(central + 32, comment2.length, true);
|
|
27041
|
-
view.setUint16(central + 36, entry.internalAttributes ?? 0, true);
|
|
27042
|
-
const mode = entry.mode & 61440 ? entry.mode : entry.mode | (entry.directory ? 16384 : entry.symlink ? 40960 : 32768);
|
|
27043
|
-
view.setUint32(central + 38, entry.externalAttributes ?? mode * 65536 + (entry.directory ? 16 : 0), true);
|
|
27044
|
-
view.setUint32(central + 42, offset, true);
|
|
27045
|
-
bytes3.set(rawName, central + 46);
|
|
27046
|
-
bytes3.set(centralExtra, central + 46 + rawName.length);
|
|
27047
|
-
bytes3.set(comment2, central + 46 + rawName.length + centralExtra.length);
|
|
27048
|
-
central += 46 + rawName.length + centralExtra.length + comment2.length;
|
|
27167
|
+
const descriptor = 0;
|
|
27168
|
+
const bytes5 = new Uint8Array(wide2 ? 24 : 16);
|
|
27169
|
+
const view3 = new DataView(bytes5.buffer);
|
|
27170
|
+
view3.setUint32(descriptor, 134695760, true);
|
|
27171
|
+
view3.setUint32(descriptor + 4, entry.crc32, true);
|
|
27172
|
+
if (wide2) {
|
|
27173
|
+
view3.setBigUint64(descriptor + 8, BigInt(entry.data.length), true);
|
|
27174
|
+
view3.setBigUint64(descriptor + 16, BigInt(entry.size), true);
|
|
27175
|
+
} else {
|
|
27176
|
+
view3.setUint32(descriptor + 8, entry.data.length, true);
|
|
27177
|
+
view3.setUint32(descriptor + 12, entry.size, true);
|
|
27178
|
+
}
|
|
27179
|
+
yield* wireChunks(bytes5, chunkSize2, signal);
|
|
27180
|
+
}
|
|
27049
27181
|
}
|
|
27182
|
+
let centralSize = 0;
|
|
27183
|
+
for (const item of encoded2) {
|
|
27184
|
+
await yieldTurn(signal);
|
|
27185
|
+
const { entry, rawName, wide: wide2, flags: flags3, centralExtra, comment: comment2, date: date2, time, offset } = item;
|
|
27186
|
+
const version = wide2 ? 45 : entry.method === 8 || flags3 & 8 ? 20 : 10;
|
|
27187
|
+
const central2 = 0;
|
|
27188
|
+
const bytes4 = new Uint8Array(46 + rawName.length + centralExtra.length + comment2.length);
|
|
27189
|
+
const view2 = new DataView(bytes4.buffer);
|
|
27190
|
+
view2.setUint32(central2, 33639248, true);
|
|
27191
|
+
view2.setUint16(central2 + 4, entry.versionMadeBy ?? 798, true);
|
|
27192
|
+
view2.setUint16(central2 + 6, version, true);
|
|
27193
|
+
view2.setUint16(central2 + 8, flags3, true);
|
|
27194
|
+
view2.setUint16(central2 + 10, entry.method, true);
|
|
27195
|
+
view2.setUint16(central2 + 12, time, true);
|
|
27196
|
+
view2.setUint16(central2 + 14, date2, true);
|
|
27197
|
+
view2.setUint32(central2 + 16, entry.crc32, true);
|
|
27198
|
+
view2.setUint32(central2 + 20, wide2 ? 4294967295 : entry.data.length, true);
|
|
27199
|
+
view2.setUint32(central2 + 24, wide2 ? 4294967295 : entry.size, true);
|
|
27200
|
+
view2.setUint16(central2 + 28, rawName.length, true);
|
|
27201
|
+
view2.setUint16(central2 + 30, centralExtra.length, true);
|
|
27202
|
+
view2.setUint16(central2 + 32, comment2.length, true);
|
|
27203
|
+
view2.setUint16(central2 + 36, entry.internalAttributes ?? 0, true);
|
|
27204
|
+
const mode = entry.mode & 61440 ? entry.mode : entry.mode | (entry.directory ? 16384 : entry.symlink ? 40960 : 32768);
|
|
27205
|
+
view2.setUint32(central2 + 38, entry.externalAttributes ?? mode * 65536 + (entry.directory ? 16 : 0), true);
|
|
27206
|
+
view2.setUint32(central2 + 42, wide2 ? 4294967295 : offset, true);
|
|
27207
|
+
bytes4.set(rawName, central2 + 46);
|
|
27208
|
+
bytes4.set(centralExtra, central2 + 46 + rawName.length);
|
|
27209
|
+
bytes4.set(comment2, central2 + 46 + rawName.length + centralExtra.length);
|
|
27210
|
+
centralSize += bytes4.length;
|
|
27211
|
+
yield* wireChunks(bytes4, chunkSize2, signal);
|
|
27212
|
+
}
|
|
27213
|
+
const bytes3 = new Uint8Array((wideArchive ? 76 : 0) + 22 + archive.comment.length);
|
|
27214
|
+
const view = new DataView(bytes3.buffer);
|
|
27215
|
+
const central = wideArchive ? writeZip64End(view, 0, encoded2.length, centralSize, localLength, localLength + centralSize) : 0;
|
|
27050
27216
|
view.setUint32(central, 101010256, true);
|
|
27051
27217
|
view.setUint16(central + 8, encoded2.length, true);
|
|
27052
27218
|
view.setUint16(central + 10, encoded2.length, true);
|
|
27053
|
-
view.setUint32(central + 12,
|
|
27054
|
-
view.setUint32(central + 16, localLength, true);
|
|
27219
|
+
view.setUint32(central + 12, centralSize, true);
|
|
27220
|
+
view.setUint32(central + 16, wideArchive ? 4294967295 : localLength, true);
|
|
27055
27221
|
view.setUint16(central + 20, archive.comment.length, true);
|
|
27056
27222
|
bytes3.set(archive.comment, central + 22);
|
|
27057
|
-
signal
|
|
27058
|
-
|
|
27223
|
+
yield* wireChunks(bytes3, chunkSize2, signal);
|
|
27224
|
+
}
|
|
27225
|
+
async function* wireChunks(bytes3, chunkSize2, signal) {
|
|
27226
|
+
for (let offset = 0; offset < bytes3.length; offset += chunkSize2) {
|
|
27227
|
+
await yieldTurn(signal);
|
|
27228
|
+
yield new Uint8Array(bytes3.subarray(offset, Math.min(bytes3.length, offset + chunkSize2)));
|
|
27229
|
+
}
|
|
27230
|
+
}
|
|
27231
|
+
async function writeZipArchive(archive, limits, signal, descriptors = false, forceZip64 = false) {
|
|
27232
|
+
return collectBytes(streamZipArchive(archive, limits, signal, descriptors, forceZip64), { maxBytes: limits.maxArchiveBytes, signal });
|
|
27059
27233
|
}
|
|
27060
27234
|
|
|
27061
27235
|
// packages/safe-bash/src/commands/archive/zip/safety.ts
|
|
@@ -27426,7 +27600,9 @@ var longOptions = {
|
|
|
27426
27600
|
"compress-6": "6",
|
|
27427
27601
|
"compress-7": "7",
|
|
27428
27602
|
"compress-8": "8",
|
|
27429
|
-
"compress-9": "9"
|
|
27603
|
+
"compress-9": "9",
|
|
27604
|
+
"force-zip64": "fz",
|
|
27605
|
+
"strip-extra": "X"
|
|
27430
27606
|
};
|
|
27431
27607
|
var reservedOptions = [
|
|
27432
27608
|
"adjust-sfx",
|
|
@@ -27446,7 +27622,6 @@ var reservedOptions = [
|
|
|
27446
27622
|
"fifo",
|
|
27447
27623
|
"filesync",
|
|
27448
27624
|
"force-descriptors",
|
|
27449
|
-
"force-zip64",
|
|
27450
27625
|
"grow",
|
|
27451
27626
|
"help",
|
|
27452
27627
|
"more-help",
|
|
@@ -27482,23 +27657,25 @@ var reservedOptions = [
|
|
|
27482
27657
|
"verbose",
|
|
27483
27658
|
"version",
|
|
27484
27659
|
"wild-stop-dirs",
|
|
27485
|
-
"strip-extra",
|
|
27486
27660
|
"archive-comment"
|
|
27487
27661
|
];
|
|
27488
27662
|
function normalizeZipOption(argument2) {
|
|
27489
27663
|
if (!argument2.startsWith("--") || argument2 === "--") return argument2;
|
|
27490
27664
|
const equal2 = argument2.indexOf("=");
|
|
27491
|
-
const
|
|
27665
|
+
const rawName = argument2.slice(2, equal2 < 0 ? void 0 : equal2);
|
|
27666
|
+
const negate2 = rawName.endsWith("-");
|
|
27667
|
+
const name2 = negate2 ? rawName.slice(0, -1) : rawName;
|
|
27492
27668
|
const names = [...Object.keys(longOptions), ...reservedOptions];
|
|
27493
27669
|
const matches2 = names.includes(name2) ? [name2] : names.filter((option) => option.startsWith(name2));
|
|
27494
27670
|
if (matches2.length > 1) throw new ZipFailure(16, "Invalid command arguments", `long option '${name2}' ambiguous`);
|
|
27495
27671
|
const matched = matches2[0];
|
|
27496
27672
|
const short = matched === void 0 ? void 0 : longOptions[matched];
|
|
27497
27673
|
if (!short) throw new ZipFailure(16, "Invalid command arguments", `unsupported option: ${argument2}`);
|
|
27674
|
+
if (negate2 && short !== "fz" && short !== "X") throw new ZipFailure(16, "Invalid command arguments", `option ${matched} is not negatable`);
|
|
27498
27675
|
if (equal2 >= 0 && short !== "i" && short !== "x" && short !== "n" && short !== "Z") {
|
|
27499
27676
|
throw new ZipFailure(16, "Invalid command arguments", `option '${matched}' does not allow a value`);
|
|
27500
27677
|
}
|
|
27501
|
-
return `-${short}${equal2 < 0 ? "" : argument2.slice(equal2)}`;
|
|
27678
|
+
return `-${short}${negate2 ? "-" : ""}${equal2 < 0 ? "" : argument2.slice(equal2)}`;
|
|
27502
27679
|
}
|
|
27503
27680
|
|
|
27504
27681
|
// packages/safe-bash/src/commands/archive/zip.ts
|
|
@@ -27530,6 +27707,8 @@ async function parse12(scope, limits) {
|
|
|
27530
27707
|
let omitDirectories = false;
|
|
27531
27708
|
let storeLinks = false;
|
|
27532
27709
|
let test = false;
|
|
27710
|
+
let zip64;
|
|
27711
|
+
let metadata3 = "default";
|
|
27533
27712
|
let level = 6;
|
|
27534
27713
|
let method = "deflate";
|
|
27535
27714
|
let suffixes = defaultStoreSuffixes;
|
|
@@ -27550,13 +27729,19 @@ async function parse12(scope, limits) {
|
|
|
27550
27729
|
for (let offset = 1; offset < argument2.length; offset++) {
|
|
27551
27730
|
const flag = argument2[offset];
|
|
27552
27731
|
if (flag === "r") recursive = true;
|
|
27553
|
-
else if (flag === "
|
|
27732
|
+
else if (flag === "f" && argument2[offset + 1] === "z") {
|
|
27733
|
+
zip64 = argument2[offset + 2] !== "-";
|
|
27734
|
+
offset += zip64 ? 1 : 2;
|
|
27735
|
+
} else if (flag === "d" || flag === "u" || flag === "f") {
|
|
27554
27736
|
const next = flag === "d" ? "delete" : flag === "u" ? "update" : "freshen";
|
|
27555
27737
|
if (action !== "add" && action !== next) throw new ZipFailure(16, "Invalid command arguments", "specify just one action");
|
|
27556
27738
|
action = next;
|
|
27557
27739
|
} else if (flag === "q") quiet = true;
|
|
27558
27740
|
else if (flag === "j") junkPaths = true;
|
|
27559
|
-
else if (flag === "
|
|
27741
|
+
else if (flag === "X") {
|
|
27742
|
+
metadata3 = argument2[offset + 1] === "-" ? "all" : "strip";
|
|
27743
|
+
if (metadata3 === "all") offset++;
|
|
27744
|
+
} else if (flag === "D") omitDirectories = true;
|
|
27560
27745
|
else if (flag === "y") storeLinks = true;
|
|
27561
27746
|
else if (flag === "T") test = true;
|
|
27562
27747
|
else if (flag === "@") stdinNames = true;
|
|
@@ -27645,7 +27830,7 @@ async function parse12(scope, limits) {
|
|
|
27645
27830
|
start = end + 1;
|
|
27646
27831
|
}
|
|
27647
27832
|
}
|
|
27648
|
-
return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
|
|
27833
|
+
return { action, archive, recursive, quiet, junkPaths, omitDirectories, storeLinks, test, zip64, metadata: metadata3, includes, excludes, level, method, suffixes, operands: [...names, ...operands], firstOperand };
|
|
27649
27834
|
}
|
|
27650
27835
|
function memberName(path, limits) {
|
|
27651
27836
|
if (path.startsWith("//") && !path.startsWith("///")) fail("UNC source paths are unsupported");
|
|
@@ -27727,8 +27912,10 @@ async function prepare(scope, parsed, budget) {
|
|
|
27727
27912
|
if (!store && parsed.level === 0 && bytes4.length && !attributes.directory && !attributes.symlink) throw new ZipFailure(5, "Internal logic error", "bad pack level");
|
|
27728
27913
|
const level = store ? 0 : parsed.level;
|
|
27729
27914
|
let entry = await makeZipEntry(name2, bytes4, attributes, limits, context2.signal, level, parsed.archive === "-" && !store);
|
|
27915
|
+
if (parsed.zip64 === true || parsed.zip64 === void 0 && source2 === "-") entry.zip64 = true;
|
|
27730
27916
|
const prior = old.get(name2);
|
|
27731
27917
|
if (prior?.comment) entry = { ...entry, comment: prior.comment };
|
|
27918
|
+
if (parsed.metadata !== "default") entry = updateZipExtras(entry, prior, parsed.metadata, limits);
|
|
27732
27919
|
if (entry.data.length > limits.maxArchiveBytes - compressedBytes) fail("archive byte limit exceeded");
|
|
27733
27920
|
compressedBytes += entry.data.length;
|
|
27734
27921
|
selected.set(name2, { entry, source: source2 });
|
|
@@ -27884,7 +28071,8 @@ async function prepare(scope, parsed, budget) {
|
|
|
27884
28071
|
append(entry, false);
|
|
27885
28072
|
}
|
|
27886
28073
|
if (!entries2.length) queue(" zip warning: zip file empty\n");
|
|
27887
|
-
|
|
28074
|
+
if (parsed.archive === "-") return { kind: "stream", archive: { entries: entries2, comment: archive.comment }, progress };
|
|
28075
|
+
const bytes3 = await writeZipArchive({ entries: entries2, comment: archive.comment }, limits, context2.signal, false, parsed.zip64 === true);
|
|
27888
28076
|
if (parsed.test && parsed.archive !== "-") {
|
|
27889
28077
|
for (const message3 of progress) await budget.output(message3);
|
|
27890
28078
|
progress.length = 0;
|
|
@@ -27910,7 +28098,7 @@ async function prepare(scope, parsed, budget) {
|
|
|
27910
28098
|
`);
|
|
27911
28099
|
}
|
|
27912
28100
|
}
|
|
27913
|
-
return { publication, bytes: bytes3, progress };
|
|
28101
|
+
return { kind: "file", publication, bytes: bytes3, progress };
|
|
27914
28102
|
}
|
|
27915
28103
|
function createZipCommand(options2 = {}) {
|
|
27916
28104
|
const limits = settings2(options2);
|
|
@@ -27924,15 +28112,18 @@ function createZipCommand(options2 = {}) {
|
|
|
27924
28112
|
if (parsed.archive === "-") budget = new Budget14({ ...context2, stdout: context2.stderr }, limits);
|
|
27925
28113
|
const prepared = await prepare(scope, parsed, budget);
|
|
27926
28114
|
if (!prepared) return { exitCode: 12 };
|
|
27927
|
-
|
|
27928
|
-
|
|
28115
|
+
if (prepared.kind === "file") {
|
|
28116
|
+
const publication = prepared.publication;
|
|
28117
|
+
if (!publication) fail("ZIP missing file publication");
|
|
27929
28118
|
await writeFileOutput(context2, prepared.bytes, () => scope.operation(() => publishZip(scope, { ...publication, bytes: prepared.bytes })));
|
|
27930
28119
|
for (const message3 of prepared.progress) await budget.output(message3);
|
|
27931
28120
|
} else {
|
|
27932
28121
|
for (const message3 of prepared.progress) await budget.output(message3);
|
|
27933
28122
|
const output2 = createOutputOperation(context2, context2.stdout);
|
|
27934
28123
|
try {
|
|
27935
|
-
await
|
|
28124
|
+
for await (const chunk of streamZipArchive(prepared.archive, limits, output2.signal, true, parsed.zip64 === true)) {
|
|
28125
|
+
await writeBytes(output2.output, chunk, output2.signal);
|
|
28126
|
+
}
|
|
27936
28127
|
} finally {
|
|
27937
28128
|
await output2.close();
|
|
27938
28129
|
}
|