summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 12:29:43 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit549cfa40e99c3d1937b742a0dba043281c687c83 (patch)
tree51966e9ee0e49ddd87738f0f89ce52a279eb0c6f /src/ninep/ctl.zig
parent54aaa0bce75e1f231d68647a9d7c0f052ed92f8e (diff)
downloadpardes-549cfa40e99c3d1937b742a0dba043281c687c83.tar.gz
pardes-549cfa40e99c3d1937b742a0dba043281c687c83.zip
A PDF's body reads the text layer of the page it shows
The body of a PDF pane read as empty. It now reads MuPDF's text extraction of the page shown, the text search and n/N already use, read-only (a write is refused, as round 22's body refusal made it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index db058ff2..be90bb6f 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2115,6 +2115,27 @@ test "a language server question that finds nothing, cannot be answered, or is a
try testing.expectEqual(E.INVAL, wr(p, Node.of(img.serial, .body), "text\n").errno());
}
+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");
+ 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 = "doc.pdf", .data = bytes });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/doc.pdf\n", .{dir}));
+ p.sync();
+ const doc = p.panes[p.active].?;
+ try testing.expect(doc.hasPdf());
+ const body = Node.of(doc.serial, .body);
+ try testing.expect(std.mem.indexOf(u8, rd(p, body, 0, 4096).bytes, "target.txt") != null);
+ try testing.expectEqual(E.INVAL, wr(p, body, "more\n").errno());
+}
+
test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();