aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-12-21 05:52:00 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-12-22 06:16:12 +0000
commite38ec79be15fe355bf50670bc9066210ae0ed211 (patch)
tree9abd0d14ba98bfd2a910d852affa5130522e0287 /osc.c
parentselection: fix crash when tripple clicking in a region containing NUL characters (diff)
osc: add option to disable OSC-52, partially or fully
Closes #1867
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/osc.c b/osc.c
index 72f3c366..2c02f53a 100644
--- a/osc.c
+++ b/osc.c
@@ -8,7 +8,7 @@
#include <sys/epoll.h>
#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';