diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-09-09 16:46:39 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-09-09 17:01:39 +0000 |
| commit | 776b831d89ff873ce1daf4e65e5eb13e808914a7 (patch) | |
| tree | 80e1a8f598925ba9821e19bddce265ba146618fa /osc.c | |
| parent | selection: add selection_<type>_has_data() (diff) | |
osc52: unset (clear) selection when an invalid payload is received
Diffstat (limited to 'osc.c')
| -rw-r--r-- | osc.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -23,17 +23,6 @@ static void osc_to_clipboard(struct terminal *term, const char *target, const char *base64_data) { - char *decoded = base64_decode(base64_data); - if (decoded == NULL) { - if (errno == EINVAL) - LOG_WARN("OSC: invalid clipboard data: %s", base64_data); - else - LOG_ERRNO("base64_decode() failed"); - return; - } - - LOG_DBG("decoded: %s", decoded); - bool to_clipboard = false; bool to_primary = false; @@ -71,6 +60,22 @@ osc_to_clipboard(struct terminal *term, const char *target, return; } + char *decoded = base64_decode(base64_data); + if (decoded == NULL) { + if (errno == EINVAL) + LOG_WARN("OSC: invalid clipboard data: %s", base64_data); + else + LOG_ERRNO("base64_decode() failed"); + + if (to_clipboard) + selection_clipboard_unset(seat); + if (to_primary) + selection_primary_unset(seat); + return; + } + + LOG_DBG("decoded: %s", decoded); + if (to_clipboard) { char *copy = xstrdup(decoded); if (!text_to_clipboard(seat, term, copy, seat->kbd.serial)) |
