fix(terminal,parser): accept OSC 52 payloads larger than 1 KiB - #102
Merged
Conversation
vte's default `no_std` feature stores the OSC buffer in a fixed 1024-byte ArrayVec, so any OSC 52 clipboard write past that size was truncated and its base64 failed to decode — copying long text over SSH silently did nothing. Disabling the feature swaps the buffer for a growable Vec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Copying from a program running over SSH silently did nothing when the text was longer than roughly 750 characters. The remote program sends the clipboard through
OSC 52;c;<base64> ST, but mmterm dropped the sequence instead of writing to the host clipboard.The cause is in the
vtedependency: its defaultno_stdfeature stores the OSC payload in a fixed 1024-byteArrayVecand stops accumulating once that buffer is full (Action::OscPutreturns early whenosc_raw.is_full()). A 981-character selection encodes to ~1308 bytes of base64, so the sequence arrived truncated,BASE64.decodefailed, andpending_clipboard_writestayedNone— no error, no clipboard update.Turning the feature off swaps the fixed buffer for a growable
Vec, which is what other terminals (Alacritty) do for the same reason. OSC 8 hyperlinks and every other OSC handler benefit from the same lift; nothing in mmterm depended on the 1 KiB cap.Changes
Cargo.toml—vte = { version = "0.13", default-features = false }, with a comment recording why the default feature is off.Cargo.lock— drops the now-unusedarrayvecdependency.CHANGELOG.md— entry under[Unreleased]→Fixed.src/terminal/parser_test.rs—osc52_write_handles_payload_larger_than_1kb, a regression test built from the exact size that failed in practice (981 chars). It fails onmainand passes with the fix.Design notes: the fix is confined to the dependency's buffer strategy —
osc_clipboardinsrc/terminal/parser.rsis unchanged, so the write/read/invalid-base64 behaviour and their existing tests stay as they were. The parser hot path is untouched;Vecgrowth only occurs while an OSC sequence is being accumulated.How to test
Automated:
New test:
osc52_write_handles_payload_larger_than_1kb. Full suite: 1245 tests pass.Manual (end-to-end):
cargo runand SSH into another host from inside mmterm.nvimwith an OSC 52 clipboard provider, or by hand:printf '\033]52;c;%s\a' "$(head -c 900 /dev/urandom | base64 -w0)").