From caa6b958d77dbfe62abd4ef69989fd76a719286a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Jan 2026 14:07:43 -0800 Subject: [PATCH] apprt/embedded: escape the initial input string Fixes #10214 --- src/apprt/embedded.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index d1d38c24d..6c1d46722 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -542,13 +542,20 @@ pub const Surface = struct { // If we have an initial input then we set it. if (opts.initial_input) |c_input| { const alloc = config.arenaAlloc(); + + // We need to escape the string because the "raw" field + // expects a Zig string. + var buf: std.Io.Writer.Allocating = .init(alloc); + defer buf.deinit(); + try std.zig.stringEscape( + std.mem.sliceTo(c_input, 0), + &buf.writer, + ); + config.input.list.clearRetainingCapacity(); try config.input.list.append( alloc, - .{ .raw = try alloc.dupeZ(u8, std.mem.sliceTo( - c_input, - 0, - )) }, + .{ .raw = try buf.toOwnedSliceSentinel(0) }, ); }