apprt/embedded: escape the initial input string

Fixes #10214
This commit is contained in:
Mitchell Hashimoto
2026-01-08 14:07:43 -08:00
parent 2766ba68ad
commit caa6b958d7

View File

@@ -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) },
);
}