fix: add ( and ) to escape characters when dropping files in gtk (#6922)

Currently when dropping files in gtk with file names that include ( or )
will generate a bash error.

With this change ( and ) will be escaped.
pull/6923/head
Jeffrey C. Ollie 2025-03-26 13:38:10 -05:00 committed by GitHub
commit 613857cf7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -23,6 +23,8 @@ pub fn ShellEscapeWriter(comptime T: type) type {
'?',
' ',
'|',
'(',
')',
=> &[_]u8{ '\\', byte },
else => &[_]u8{byte},
};
@ -93,3 +95,12 @@ test "shell escape 6" {
try writer.writeAll("a\"c");
try testing.expectEqualStrings("a\\\"c", fmt.getWritten());
}
test "shell escape 7" {
var buf: [128]u8 = undefined;
var fmt = std.io.fixedBufferStream(&buf);
var shell: ShellEscapeWriter(@TypeOf(fmt).Writer) = .{ .child_writer = fmt.writer() };
const writer = shell.writer();
try writer.writeAll("a(1)");
try testing.expectEqualStrings("a\(1\)", fmt.getWritten());
}