feat(osc52) clipboard - #20896
Conversation
Make base64 functions and args independent from vimscript and its blob_T type.
Add following to `feature.h` to test. diff --git a/src/feature.h b/src/feature.h --- a/src/feature.h +++ b/src/feature.h @@ -1003,6 +1004,10 @@ */ #if defined(HAVE_TGETENT) # define FEAT_TERMRESPONSE +# define FEAT_CLIPBOARD_OSC52 +# ifndef FEAT_CLIPBOARD +# define FEAT_CLIPBOARD_OSC52_TINY +# endif #endif
| dnl OSC 52 clipboard support. | ||
| AC_MSG_CHECKING(--enable-osc52 argument) | ||
| AC_ARG_ENABLE(osc52, | ||
| [ --enable-osc52[=OPTS] OSC 52 Clipboard [default=yes] [OPTS=no/yes/only]], , enable_osc52="no") |
There was a problem hiding this comment.
I don't think we need a feature flag for this in my opinion. This feature is small and requires no dependencies
There was a problem hiding this comment.
Not +osc52 in version? or do u mean the FEAT_ vars? If not enabled its good to check in version as its non-default.
There was a problem hiding this comment.
I meant the FEAT_ vars. However this would make +clipboard permanently enabled, which may confuse people, so I am not sure
There was a problem hiding this comment.
Reason for the 2 vars _TINY and regular is because its vastly different in impl - one is literally enabling system clipboard registers raw and minimal (this state of commits).
Reason for the _ONLY var was same, maybe it can be inferred from -wayland,-x11 I can look into it.
It also needs to avoid not doing lots if !FEAT_CLIPBOARD cuz there are way too many.. it completely avoids that now.
|
I don't see any code integrating this with |
I have it, I was switching pc a lot at the time due to warranty of part. So yes, |
|
thanks for working on this and thanks for careful thinking of exfiltration attacks. Assuming enabling osc52 handling does not add much code for vim tiny, wouldn't it be much more useful to always enable this for tiny builds, instead of giving distributions the choice to disable it for their own tiny vim? It would still have to be explicitly enabled by users during runtime, and I don't see why distributions would need to disable it. On another point, how well is OSC52 actually supported by terminals nowadays? I read that writing to the clipboard is even more widely supported than reading the clipboard by terminals (for the same security concerns)? Is that true? And finally, I am not so sure the |
Thanks sincerely for your always valued input @chrisbra and greatly appreciated continued effort in maintaining and handling everything (also the smaller side-projects and aspects which I can only imagine are larger than most think !)
Try
Its my wish and intention, that they look positively on this and embrace it - also why I am hesistant to rush it, but lets imagine for a moment, that this lands first as somewhat of a sleeper-feature (dormant, word of mouth, builds hype), matures and gets feedback and we listen to the major, common distro concerns.
Honestly, I still believe writing openssh mailing list and hoping(🦜) for a positive and caring response would yield best results long-term, even if it initially seems unlikely. It would remove the hindrance of distributions flat out rejecting it, because they are afraid of being called out, or compared, (or whatever). With approval and access-controls in
Let me clarify:
Argument: ... lets investigate how many envvars are actually read right now besides the usual suspects netbeans.c is by far the largest user of envvars. os_win32.c has a few. A quick sweep follows of support (not verified 100%, take with grain of salt - just did a quick search and tried to find sources): Terminal supportRead+write support:
Write only support (defaults not checked): Stumbled upon a good writeup with considerations here: https://miliucci.org/post/linux-terminals-osc-52-escape/ the best part argument; tl;dr conclusion of article: |
Just letting you know I am still working on this, thus leaving this for input.
I have spend time polishing and minimizing the tiny version, but have everything else implemented for
normal,huge, but I need to merge it into my new base and its getting late.Issue: #19441
Plan:
Configure, Feature
[ --enable-osc52[=OPTS](not supported with --enable-gui)(*
default=yesmeans--enable-osc52without explicit=yes|onlychoice)yesFEAT_CLIPBOARD_OSC52(andFEAT_CLIPBOARD_OSC52_TINYif built on tiny.)onlyx11,waylandin configure making a super minimalclipboardterminal setup.What lacks in tiny:
DA1andXTGETTCAP(also useful for clipboard syncronization)
When enabled
:version:Because the features are similar to regular
clipboardbut it does not haveclipboard_provideretc. All other code is bypassed, it does not enableFEAT_CLIPBOARDit just shows the feature as it is otherwise fully compatible with the provided features.Environment variable
(most relevant to tiny version, but also works on regular build)
VIMOSC52=1, enables"+, and"*registers loading content at startup fromOSC52 p,cprimary/clipboardWhy env var?
Functions as an entrypoint for your regular sysadmin/devops who have no readwrite access/forbidden to customize config and just want clipboard working remotely on servers he trusts.
Integration with
clipboard.con regular buildCurrent suggestion is that it defaults to
wayland,x11,osc52if built with--enable-osc52=yes.If
VIMOSC52=1is used on regular build it reordersclipmethodtoMeaning it prioritizes it first. Same argument as described above for tiny; make the feature extremely accessible to anyone; even system admins who never really configures vim.
vimrc configuration is an explicit, non-default - ordered to your liking.
Configuration is explicit, non-default, always for this feature.
Doc
options.txt (
--enable=onlynot listed here as all other backends disabled)term.txt
Detection
DA1andXTGETTCAP Msis supported in regular builds.Additional notes
Timeouts, performance
In my draft for regular builds it is thus with timeout on reading:
250ms over ssh, 100ms on regular PC.
(non-blocking btw)
In my testing 10MB clipboard on a Ryzen 7900 finishes as fast as
31ms, quite impressive.Thus it is also extremely unlikely to fail unless OOM, all-core workload, or over ssh.
It is more likely that a wayland or x11 connection will trip requiring
:wlrestore,:xrestorein my experience.I don't think there are reliable probes into system loadavg that can scale with loadavg, nor do I think network provides a similar probe of performance, however one could scale with the highest recorded timeout over a flaky ssh connection - always expecting output on the other side.
As soon as it receives first byte, it knows that there is actually coming data and can increase timeout sensibly.
I am biased to sensible defaults, basically no configuration and scaling timeout if done correctly.
For errors/warning I am considering if these are sufficient for regular build.
Security
Its not enabled by default for neither
configurenorvimrcand if you have reading enabled in your terminal emulator there are plenty of attack vectors already, vim is not the only one - you could have one waiting for you in .bashrc 🤥Imho, if anyone should filter
osc52it should be.ssh/configsimilar to howX11Forwarding=is as toggle, but they will probably point at terminal emulators; even if they chose to support the now fading x11 support.