diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 13:53:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | bb770b12a4ab9ef7dbeee9ade5a1e51e90b4d15b (patch) | |
| tree | 2d52699d01e15466ace122262a379b39ec8cbad1 /src/ninep | |
| parent | 6dcacb15c53b2f032a573ed10e39777bc281a481 (diff) | |
| download | pardes-bb770b12a4ab9ef7dbeee9ade5a1e51e90b4d15b.tar.gz pardes-bb770b12a4ab9ef7dbeee9ade5a1e51e90b4d15b.zip | |
A PDF that cannot be read fails its look with its path and why
A truncated PDF said only look: <error>, with no path, where an image that cannot be read names both. It now says look: <path>: not a PDF pardes can read: <why>.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index ebb85609..a11bfeda 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2140,6 +2140,23 @@ test "a corrupt image fails its look with an err, and no pane is made" { try testing.expectEqual(count, after); } +test "a truncated PDF fails its look with its path and why" { + if (comptime !pardes.pdf_enabled) return; + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + const bytes = try @import("mupdf").makeLinksTestPdf(testing.allocator); + defer testing.allocator.free(bytes); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "cut.pdf", .data = bytes[0..40] }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + const r = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/cut.pdf\n", .{dir})); + try testing.expectEqual(Status.err, r.reply.status); + try testing.expect(std.mem.indexOf(u8, r.reply.ename, "cut.pdf: not a PDF pardes can read: ") != null); +} + test "a PDF's body reads its page's text layer, and takes no write" { if (comptime !pardes.pdf_enabled) return; const p = try withFile(testing.allocator, "x\n"); |
