aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--osc.c13
2 files changed, 9 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 82b4238b..329a7650 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -114,6 +114,7 @@
only ([#1846][1846]).
* Drop required version of libxkbcommon from 1.8.0 back to 1.0.0
([#2103][2103]).
+* OSC-52: an empty payload now clears the clipboard.
[1846]: https://codeberg.org/dnkl/foot/issues/1846
[2103]: https://codeberg.org/dnkl/foot/issues/2103
diff --git a/osc.c b/osc.c
index d59adc5a..834029c1 100644
--- a/osc.c
+++ b/osc.c
@@ -73,16 +73,19 @@ osc_to_clipboard(struct terminal *term, const char *target,
}
char *decoded = base64_decode(base64_data, NULL);
- if (decoded == NULL) {
- if (errno == EINVAL)
- LOG_WARN("OSC: invalid clipboard data: %s", base64_data);
- else
- LOG_ERRNO("base64_decode() failed");
+ if (decoded == NULL || decoded[0] == '\0') {
+ 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);
+ free(decoded);
return;
}