Fix chunking of t=k not handling metadata present only on first chunk

This commit is contained in:
Kovid Goyal 2026-04-19 12:52:00 +05:30
parent 13add3532b
commit dc9bf889a6
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 15 additions and 2 deletions

View file

@ -1238,6 +1238,7 @@ drag_free_offer(Window *w) {
ds.state = DRAG_SOURCE_NONE;
ds.pre_sent_total_sz = 0;
ds.images_sent_total_sz = 0;
zero_at_ptr(&ds.in_flight_remote_file_data);
}
static void
@ -1907,6 +1908,16 @@ void
drag_remote_file_data(
Window *w, int32_t x, int32_t y, int32_t X, int32_t Y, bool has_more, const uint8_t *payload, size_t payload_sz
) {
if (ds.in_flight_remote_file_data.active) {
x = ds.in_flight_remote_file_data.x; y = ds.in_flight_remote_file_data.y;
ds.in_flight_remote_file_data.Y = Y; ds.in_flight_remote_file_data.X = X;
}
if (!has_more) zero_at_ptr(&ds.in_flight_remote_file_data);
else if (!ds.in_flight_remote_file_data.active) {
ds.in_flight_remote_file_data.active = true;
ds.in_flight_remote_file_data.x = x; ds.in_flight_remote_file_data.y = y;
ds.in_flight_remote_file_data.Y = Y; ds.in_flight_remote_file_data.X = X;
}
size_t item_idx = ds.num_mimes;
for (size_t i = 0; i < ds.num_mimes; i++) {
if (ds.items[i].requested_remote_files) {

View file

@ -319,6 +319,7 @@ typedef struct Window {
struct { double x, y; monotonic_t at; } initial_left_press;
char *mimes_buf; size_t num_mimes, bufsz;
size_t total_remote_data_size;
struct { int32_t x, y, X, Y; bool active; } in_flight_remote_file_data;
struct {
const char *mime_type; uint8_t *optional_data; size_t data_size, data_capacity; base64_state base64_state;
bool data_decode_initialized, is_uri_list, requested_remote_files;

View file

@ -200,7 +200,7 @@ def client_drag_cancel(client_id: int = 0) -> bytes:
def client_remote_file(
uri_idx: int, data_b64: str = '', *,
uri_idx: int = 0, data_b64: str = '', *,
item_type: int = 0, more: bool = False,
parent_handle: int = 0, entry_num: int = 0,
client_id: int = 0,
@ -2935,7 +2935,7 @@ class TestDnDProtocol(BaseTest):
b64_2 = standard_b64encode(chunk2).decode()
parse_bytes(screen, client_remote_file(1, b64_1, item_type=2, more=True))
self._assert_no_output(cap, wid)
parse_bytes(screen, client_remote_file(1, b64_2, item_type=2))
parse_bytes(screen, client_remote_file(data_b64=b64_2))
self._assert_no_output(cap, wid)
# End of listing
parse_bytes(screen, client_remote_file(1, '', item_type=2))
@ -2945,6 +2945,7 @@ class TestDnDProtocol(BaseTest):
b64 = standard_b64encode(b'c1').decode()
parse_bytes(screen, client_remote_file(
1, b64, item_type=0, parent_handle=2, entry_num=1))
self._assert_no_output(cap, wid)
parse_bytes(screen, client_remote_file(
1, '', item_type=0, parent_handle=2, entry_num=1))
self._assert_no_output(cap, wid)