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.
This commit is contained in:
Jeffrey C. Ollie
2025-03-26 13:38:10 -05:00
committed by GitHub

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());
}