From e38ec79be15fe355bf50670bc9066210ae0ed211 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 21 Dec 2024 06:52:00 +0100 Subject: osc: add option to disable OSC-52, partially or fully Closes #1867 --- osc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'osc.c') diff --git a/osc.c b/osc.c index 72f3c366..2c02f53a 100644 --- a/osc.c +++ b/osc.c @@ -8,7 +8,7 @@ #include #define LOG_MODULE "osc" -#define LOG_ENABLE_DBG 0 +#define LOG_ENABLE_DBG 1 #include "log.h" #include "base64.h" #include "config.h" @@ -64,6 +64,14 @@ osc_to_clipboard(struct terminal *term, const char *target, return; } + const bool copy_allowed = term->conf->security.osc52 == OSC52_ENABLED + || term->conf->security.osc52 == OSC52_COPY_ENABLED; + + if (!copy_allowed) { + LOG_DBG("ignoring copy request: disabled in configuration"); + return; + } + char *decoded = base64_decode(base64_data, NULL); if (decoded == NULL) { if (errno == EINVAL) @@ -190,6 +198,13 @@ osc_from_clipboard(struct terminal *term, const char *source) return; } + const bool paste_allowed = term->conf->security.osc52 == OSC52_ENABLED + || term->conf->security.osc52 == OSC52_PASTE_ENABLED; + if (!paste_allowed) { + LOG_DBG("ignoring paste request: disabled in configuration"); + return; + } + /* Use clipboard if no source has been specified */ char src = source[0] == '\0' ? 'c' : 0; bool from_clipboard = src == 'c'; -- cgit v1.3