This example demonstrates how to use the paste utilities to check if paste data is safe before sending it to the terminal.
#include <stdio.h>
#include <string.h>
int main() {
const char *safe_data = "hello world";
printf("'%s' is safe to paste\n", safe_data);
}
const char *unsafe_newline = "rm -rf /\n";
printf("'%s' is UNSAFE - contains newline\n", unsafe_newline);
}
const char *unsafe_escape = "evil\x1b[201~code";
printf("Data with escape sequence is UNSAFE\n");
}
const char *empty_data = "";
printf("Empty data is safe\n");
}
return 0;
}
bool ghostty_paste_is_safe(const char *data, size_t len)