mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-06 01:40:22 -05:00
osc52: unset (clear) selection when an invalid payload is received
This commit is contained in:
parent
dec6f963cb
commit
776b831d89
2 changed files with 18 additions and 11 deletions
|
|
@ -112,6 +112,8 @@
|
||||||
* Handling of multi-column composed characters while reflowing.
|
* Handling of multi-column composed characters while reflowing.
|
||||||
* Escape sequences sent for key combinations with `Return`, that did
|
* Escape sequences sent for key combinations with `Return`, that did
|
||||||
**not** include `Alt`.
|
**not** include `Alt`.
|
||||||
|
* Clipboard (or primary selection) is now cleared when receiving an
|
||||||
|
OSC-52 command with an invalid base64 encoded payload.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
27
osc.c
27
osc.c
|
|
@ -23,17 +23,6 @@ static void
|
||||||
osc_to_clipboard(struct terminal *term, const char *target,
|
osc_to_clipboard(struct terminal *term, const char *target,
|
||||||
const char *base64_data)
|
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_clipboard = false;
|
||||||
bool to_primary = false;
|
bool to_primary = false;
|
||||||
|
|
||||||
|
|
@ -71,6 +60,22 @@ osc_to_clipboard(struct terminal *term, const char *target,
|
||||||
return;
|
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) {
|
if (to_clipboard) {
|
||||||
char *copy = xstrdup(decoded);
|
char *copy = xstrdup(decoded);
|
||||||
if (!text_to_clipboard(seat, term, copy, seat->kbd.serial))
|
if (!text_to_clipboard(seat, term, copy, seat->kbd.serial))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue