mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal: add sanitize.zig
This commit is contained in:
13
src/terminal/sanitize.zig
Normal file
13
src/terminal/sanitize.zig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
/// Returns true if the data looks safe to paste.
|
||||||
|
pub fn isSafePaste(data: []const u8) bool {
|
||||||
|
return std.mem.indexOf(u8, data, "\n") == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
test isSafePaste {
|
||||||
|
const testing = std.testing;
|
||||||
|
try testing.expect(isSafePaste("hello"));
|
||||||
|
try testing.expect(!isSafePaste("hello\n"));
|
||||||
|
try testing.expect(!isSafePaste("hello\nworld"));
|
||||||
|
}
|
Reference in New Issue
Block a user