-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Touffy/fix-small-files-with-large-offsets
Fix Zip64 header for small files with large offsets
- Loading branch information
Showing
5 changed files
with
32 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { assertEquals, assertStrictEquals } from "https://deno.land/std/testing/asserts.ts" | ||
import { assertEquals, assertStrictEquals } from "https://deno.land/[email protected]/testing/asserts.ts" | ||
import { Buffer } from "https://deno.land/[email protected]/io/buffer.ts" | ||
import { fileHeader, fileData, dataDescriptor, centralHeader, zip64ExtraField } from "../src/zip.ts" | ||
import type { ZipFileDescription } from "../src/input.ts" | ||
|
||
|
@@ -19,7 +20,7 @@ Deno.test("the ZIP fileHeader function makes file headers", () => { | |
|
||
Deno.test("the ZIP fileData function yields all the file's data", async () => { | ||
const file = {...baseFile} | ||
const actual = new Deno.Buffer() | ||
const actual = new Buffer() | ||
for await (const chunk of fileData(file)) actual.writeSync(chunk) | ||
assertEquals(actual.bytes({copy: false}), zipSpec) | ||
}) | ||
|
@@ -50,23 +51,23 @@ Deno.test("the ZIP dataDescriptor function makes ZIP64 data descriptors", () => | |
Deno.test("the ZIP centralHeader function makes central record file headers", () => { | ||
const file = {...baseFile, uncompressedSize: 0x10203040n, crc: 0x12345678} | ||
const offset = 0x01020304n | ||
const actual = centralHeader(file, offset, false) | ||
const actual = centralHeader(file, offset, 0) | ||
const expected = BufferFromHex("504b01022d032d000800000000109a4e7856341240302010403020100b0000000000000000000000b48104030201") | ||
assertEquals(actual, expected) | ||
}) | ||
|
||
Deno.test("the ZIP centralHeader function makes ZIP64 central record file headers", () => { | ||
const file = {...baseFile, uncompressedSize: 0x110203040n, crc: 0x12345678} | ||
const offset = 0x101020304n | ||
const actual = centralHeader(file, offset, true) | ||
const actual = centralHeader(file, offset, 28) | ||
const expected = BufferFromHex("504b01022d032d000800000000109a4e78563412ffffffffffffffff0b001c000000000000000000b481ffffffff") | ||
assertEquals(actual, expected) | ||
}) | ||
|
||
Deno.test("the ZIP zip64ExtraField function makes Zip64 extra fields", () => { | ||
const file = {...baseFile, uncompressedSize: 0x10203040n, crc: 0x12345678} | ||
const offset = 0x01020304n | ||
const actual = zip64ExtraField(file, offset) | ||
const actual = zip64ExtraField(file, offset, 28) | ||
const expected = BufferFromHex("01001800403020100000000040302010000000000403020100000000") | ||
assertEquals(actual, expected) | ||
}) |