mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
terminal: OSC parses 4 with empty string param without crashing
This commit is contained in:
@ -445,8 +445,14 @@ pub const Parser = struct {
|
|||||||
|
|
||||||
.color_palette_index => switch (c) {
|
.color_palette_index => switch (c) {
|
||||||
'0'...'9' => {},
|
'0'...'9' => {},
|
||||||
';' => {
|
';' => blk: {
|
||||||
if (std.fmt.parseUnsigned(u8, self.buf[self.buf_start .. self.buf_idx - 1], 10)) |num| {
|
const str = self.buf[self.buf_start .. self.buf_idx - 1];
|
||||||
|
if (str.len == 0) {
|
||||||
|
self.state = .invalid;
|
||||||
|
break :blk;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std.fmt.parseUnsigned(u8, str, 10)) |num| {
|
||||||
self.state = .color_palette_index_end;
|
self.state = .color_palette_index_end;
|
||||||
self.temp_state = .{ .num = num };
|
self.temp_state = .{ .num = num };
|
||||||
} else |err| switch (err) {
|
} else |err| switch (err) {
|
||||||
@ -1254,3 +1260,15 @@ test "OSC: show desktop notification with title" {
|
|||||||
try testing.expectEqualStrings(cmd.show_desktop_notification.title, "Title");
|
try testing.expectEqualStrings(cmd.show_desktop_notification.title, "Title");
|
||||||
try testing.expectEqualStrings(cmd.show_desktop_notification.body, "Body");
|
try testing.expectEqualStrings(cmd.show_desktop_notification.body, "Body");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "OSC: empty param" {
|
||||||
|
const testing = std.testing;
|
||||||
|
|
||||||
|
var p: Parser = .{};
|
||||||
|
|
||||||
|
const input = "4;;";
|
||||||
|
for (input) |ch| p.next(ch);
|
||||||
|
|
||||||
|
const cmd = p.end('\x1b');
|
||||||
|
try testing.expect(cmd == null);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user