mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-10 04:27:45 -05:00
osc: bug: uneven clipboard bytes where not buffered correctly
When responding to a OSC 52 clipboard request, we need to base64 encode the clipboard data. This is done in, potentially, several calls. Since we need at least 3 bytes to be able to produce any base64 output, we may have to buffer up to 2 bytes between the callback calls with clipboard data. This was being done incorrectly, where both bytes were written to index 0 in the buffer.
This commit is contained in:
parent
9a0d440e95
commit
e2229c7e2e
1 changed files with 4 additions and 2 deletions
6
osc.c
6
osc.c
|
|
@ -111,10 +111,12 @@ from_clipboard_cb(const char *text, size_t size, void *user)
|
|||
if (left == 0)
|
||||
return;
|
||||
|
||||
assert(ctx->idx == 0);
|
||||
|
||||
int remaining = left % 3;
|
||||
for (int i = remaining; i > 0; i--)
|
||||
ctx->buf[0] = text[size - i];
|
||||
ctx->idx = remaining;
|
||||
ctx->buf[ctx->idx++] = text[size - i];
|
||||
assert(ctx->idx == remaining);
|
||||
|
||||
char *chunk = base64_encode((const uint8_t *)t, left / 3 * 3);
|
||||
assert(chunk != NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue