GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): accept TIFF Exif and GPS pointers stored as IFD type 13 · pingdotgg/t3code@437027d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/files
    • AttachmentFilePreview.browser.test.tsx
    • imageDecode.worker.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+31-11Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -514,14 +514,16 @@ describe("bounded binary previews", () => {
514514
}
515515
});
516516

517-
it("keeps WhiteIsZero TIFF brightness and alpha with SubIFDs tags and rejects oversized metadata before decoding", async () => {
517+
it("keeps WhiteIsZero TIFF brightness and alpha with SubIFDs and type-13 ExifIFD pointers and rejects invalid metadata before decoding", async () => {
518518
let bytes = new ArrayBuffer(0);
519+
let exifEntry = 0;
519520
for (const { pixels, expected } of [
520521
{ pixels: [0, 255], expected: [255, 255, 255, 255, 0, 0, 0, 255] },
521522
{ pixels: [0, 255, 255, 0], expected: [255, 255, 255, 255, 0, 0, 0, 0] },
522523
]) {
523524
const samples = pixels.length / 2;
524-
const start = samples === 2 ? 158 : 146;
525+
const start = samples === 2 ? 170 : 158;
526+
const exif = start + pixels.length;
525527
const tags = [
526528
[256, 2],
527529
[257, 1],
@@ -535,8 +537,10 @@ describe("bounded binary previews", () => {
535537
[284, 1],
536538
[330, 0, 13],
537539
...(samples === 2 ? [[338, 2]] : []),
540+
[34665, exif, 13],
538541
];
539-
bytes = new ArrayBuffer(start + pixels.length);
542+
exifEntry = 10 + (tags.length - 1) * 12;
543+
bytes = new ArrayBuffer(exif + 8);
540544
const view = new DataView(bytes);
541545
view.setUint16(0, 0x4949);
542546
view.setUint16(2, 42, true);
@@ -563,14 +567,30 @@ describe("bounded binary previews", () => {
563567
URL.revokeObjectURL(src);
564568
}
565569
}
566-
new DataView(bytes).setUint32(14, 1_000_000, true);
567-
const invalid = URL.createObjectURL(new Blob([bytes]));
568-
try {
569-
await expect(
570-
decodeImagePreview(invalid, false, new AbortController().signal),
571-
).rejects.toThrow("metadata");
572-
} finally {
573-
URL.revokeObjectURL(invalid);
570+
for (const [mutate, message] of [
571+
[
572+
(view: DataView) => view.setUint16(exifEntry + 2, 3, true),
573+
"Invalid TIFF metadata pointer.",
574+
],
575+
[
576+
(view: DataView) => view.setUint32(exifEntry + 4, 2, true),
577+
"Invalid TIFF metadata pointer.",
578+
],
579+
[
580+
(view: DataView) => view.setUint32(14, 1_000_000, true),
581+
"This TIFF has too much or truncated metadata.",
582+
],
583+
] as const) {
584+
const copy = bytes.slice(0);
585+
mutate(new DataView(copy));
586+
const invalid = URL.createObjectURL(new Blob([copy]));
587+
try {
588+
await expect(
589+
decodeImagePreview(invalid, false, new AbortController().signal),
590+
).rejects.toThrow(message);
591+
} finally {
592+
URL.revokeObjectURL(invalid);
593+
}
574594
}
575595
});
576596
});
Collapse file

‎apps/web/src/components/files/imageDecode.worker.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/files/imageDecode.worker.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function validateTiffMetadata(bytes: ArrayBuffer) {
3434
if (start + length > bytes.byteLength || allocation > 8 * 1024 * 1024)
3535
throw new PreviewError({ code: "tiff-metadata-truncated" });
3636
if (tag === 0x8769 || tag === 0x8825) {
37-
if (type !== 4 || values !== 1) throw new PreviewError({ code: "tiff-metadata-pointer" });
37+
if ((type !== 4 && type !== 13) || values !== 1)
38+
throw new PreviewError({ code: "tiff-metadata-pointer" });
3839
inspect(view.getUint32(entry + 8, littleEndian), depth + 1);
3940
}
4041
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.