mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-17 21:12:39 +00:00
os: fix off-by-one error in ShellEscapeWriter
I am truly not sure why the tests never caught this, but I just fell for the oldest trick in the book
This commit is contained in:
@@ -5,8 +5,6 @@ const Writer = std.Io.Writer;
|
||||
/// Writer that escapes characters that shells treat specially to reduce the
|
||||
/// risk of injection attacks or other such weirdness. Specifically excludes
|
||||
/// linefeeds so that they can be used to delineate lists of file paths.
|
||||
///
|
||||
/// T should be a Zig type that follows the `std.Io.Writer` interface.
|
||||
pub const ShellEscapeWriter = struct {
|
||||
writer: Writer,
|
||||
child: *Writer,
|
||||
@@ -33,7 +31,7 @@ pub const ShellEscapeWriter = struct {
|
||||
var count: usize = 0;
|
||||
for (data[0 .. data.len - 1]) |chunk| try self.writeEscaped(chunk, &count);
|
||||
|
||||
for (0..splat) |_| try self.writeEscaped(data[data.len], &count);
|
||||
for (0..splat) |_| try self.writeEscaped(data[data.len - 1], &count);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user