mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
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) {
|
switch (cmd) {
|
||||||
.change_window_title => |title| {
|
.change_window_title => |title| {
|
||||||
if (@hasDecl(T, "changeWindowTitle")) {
|
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);
|
try self.handler.changeWindowTitle(title);
|
||||||
return;
|
return;
|
||||||
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
} else log.warn("unimplemented OSC callback: {}", .{cmd});
|
||||||
@ -1627,6 +1632,30 @@ test "stream: XTSHIFTESCAPE" {
|
|||||||
try testing.expect(s.handler.escape.? == true);
|
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" {
|
test "stream: insert characters" {
|
||||||
const H = struct {
|
const H = struct {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
Reference in New Issue
Block a user