Clarify that the size limit refers to size of data before base64 encoding

This commit is contained in:
Kovid Goyal 2025-02-15 10:17:59 +05:30
parent fc8e678eb5
commit 0eb4959a56
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 4 deletions

View file

@ -47,7 +47,8 @@ The terminal emulator will reply with a sequence of escape codes of the form::
Here, the ``status=DATA`` packets deliver the data (as base64 encoded bytes)
associated with each MIME type. The terminal emulator should chunk up the data
for an individual type, into chunks of size **no more** than 4096 bytes. All
for an individual type, into chunks of size **no more** than 4096 bytes (4096
is the size of a chunk *before* base64 encoding). All
the chunks for a given type must be transmitted sequentially and only once they
are done the chunks for the next type, if any, should be sent. The end of data
is indicated by a ``status=DONE`` packet.
@ -90,7 +91,8 @@ following sequence of packets::
The final packet with no mime and no data indicates end of transmission. The
data for every MIME type should be split into chunks of no more than 4096
bytes. All the chunks for a given MIME type must be sent sequentially, before
bytes (4096 is the size of the data before base64 encoding).
All the chunks for a given MIME type must be sent sequentially, before
sending chunks for the next MIME type. After the transmission is complete, the
terminal replies with a single packet indicating success::

View file

@ -24,6 +24,8 @@ from .fast_data_types import (
)
from .utils import log_error
READ_RESPONSE_CHUNK_SIZE = 4096
class Tempfile:
@ -462,8 +464,8 @@ class ClipboardRequestManager:
assert w is not None
mv = memoryview(data)
while mv:
w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(payload=mv[:4096], mime=current_mime))
mv = mv[4096:]
w.screen.send_escape_code_to_child(ESC_OSC, rr.encode_response(payload=mv[:READ_RESPONSE_CHUNK_SIZE], mime=current_mime))
mv = mv[READ_RESPONSE_CHUNK_SIZE:]
for mime in rr.mime_types:
current_mime = mime