mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
Merge pull request #1364 from mitchellh/title-utf8
terminal: ignore change window title requests with invalid UTF-8
This commit is contained in:
@ -978,6 +978,11 @@ pub fn Stream(comptime Handler: type) type {
|
||||
switch (cmd) {
|
||||
.change_window_title => |title| {
|
||||
if (@hasDecl(T, "changeWindowTitle")) {
|
||||
if (!std.unicode.utf8ValidateSlice(title)) {
|
||||
log.warn("change title request: invalid utf-8, ignoring request", .{});
|
||||
return;
|
||||
}
|
||||
|
||||
try self.handler.changeWindowTitle(title);
|
||||
return;
|
||||
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
||||
@ -1627,6 +1632,30 @@ test "stream: XTSHIFTESCAPE" {
|
||||
try testing.expect(s.handler.escape.? == true);
|
||||
}
|
||||
|
||||
test "stream: change window title with invalid utf-8" {
|
||||
const H = struct {
|
||||
seen: bool = false,
|
||||
|
||||
pub fn changeWindowTitle(self: *@This(), title: []const u8) !void {
|
||||
_ = title;
|
||||
|
||||
self.seen = true;
|
||||
}
|
||||
};
|
||||
|
||||
{
|
||||
var s: Stream(H) = .{ .handler = .{} };
|
||||
try s.nextSlice("\x1b]2;abc\x1b\\");
|
||||
try testing.expect(s.handler.seen);
|
||||
}
|
||||
|
||||
{
|
||||
var s: Stream(H) = .{ .handler = .{} };
|
||||
try s.nextSlice("\x1b]2;abc\xc0\x1b\\");
|
||||
try testing.expect(!s.handler.seen);
|
||||
}
|
||||
}
|
||||
|
||||
test "stream: insert characters" {
|
||||
const H = struct {
|
||||
const Self = @This();
|
||||
|
Reference in New Issue
Block a user