-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do something about the clipboard on insecure domains and Firefox #1106
Comments
|
We can work around copying, it's the pasting that's a problem. :( |
why is it so hard to generate a self signed cert for general development use and allow that in the browser via import? You do that once you can reuse the certs for your own dev projects always and its done where is the problem=? |
Not everyone has the expense to do that, please consider those implications and never assume people to do one thing and do it correctly. This is not open for debate per se. |
Well, some cloud platforms set certificate as enterprise version paid function, so some personal small projects have no way to enable https. |
@easychen show me a link to such a offer. In general you can always get public signed certs from letsencrypt and private once for your company via any PC in that company |
@easychen to make my point clear if your using http + auth or without it does not matter your working with clear text over many hops this is not acceptable in 2019 as you expose everything over the line. Even More ClearA Login / JWT Token in the http Header of every Request in Clear Text is like Opening it for the Internet. A Cookie makes not much diffrence |
Is it really so hard to make copy-paste working in terminal even on not trusted connections? Is confusing error message: "cannot read property writeText" really better than making it work (maybe with some warning about the certificate issue)? It works in Jupyterlab terminal for example.. |
it's not the fee for the certs self , it's for uploading certs to your apps. https://www.sinacloud.com/index/price.html
We DO login via https, but just use this for temp online sandbox under a separate subdomain for every users. And not all cloud platform has api to upload the certs ... |
If we really need to make the clipboard work on insecure domains the only thing we can do is allow the native keybindings through and listen to the As long as the browser supports Chrome supports Also note you can use This is probably a change that should be made upstream, though, rather than patched in It would be wise to use SSL even for a temporary sandbox though, right? |
We will when possible, it's not a tech problem but a financial one. Version 1 is good enough for us, great thanks for your excellent work. For the pasting problem, I see it works ( cmd+v ) under insecurity domain, maybe I missing something?
|
My guess is that That actually presents an interesting workaround. If you're using Chrome and |
Neat! So for anyone else having the problem, currently the workaround is to search in the keyboard shortcuts for "workbench.action.terminal.paste" then remove the keybinding ( The long-term plan: when the clipboard API isn't available, don't bind those keys. |
this is also the case in upstream microsoft/vscode#83595, microsoft/vscode#83598 |
We'll wait for upstream fix and see what we can do. |
Another note about this on Firefox. Firefox doesn't support the clipboard API at all apparently (at least not on websites) and it also doesn't bind Ctrl+Shift+V so the above workaround doesn't work. The only solution as far as I can tell is to use So there's currently no workaround for Firefox and it won't work even in a secure context. |
Oh actually as previously mentioned |
@code-asher the problem even exist in theia |
Another workaround for Firefox: Shift + Right-click opens the context menu, and you can simply click paste. Middle-click did not work for me. |
From #1725
@LindsayWeir Not sure why it doesn't work on iPad, maybe the clipboard API isn't implemented there. We should show a message there as well @code-asher |
I was updating from 3.2.0 to 3.4.1. When I use |
Is this just on Firefox? What about using the native context menu adding the VS Code ones with this? It would be slightly more cluttered and wouldn't fit the VS Code theme, but I think that's worth it (or it could be optional). |
You have to right click in the actual terminal, it looks like you're right-clicking on the right-click menu |
I have the same issue with Chrome, what's the workaround for it? |
|
Can confirm, shift + insert also works for me in Firefox on Windows 7. |
Looking at Mozilla's developer documentation this seems related to an experimental Blink-only feature "ClipboardItem." https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API |
I found a workaround for Firefox! Just set |
THANK YOU SO MUCH! |
@Miguelklappes If you are not being sarcastic, why did you give my comment a thumbs down? |
By mistake!! I wasn't being sarcastic haha |
hey it seems something changed? with the latest FF version (and Codeserver Version 3.10.1) I can copy paste (CTRL+C, CTRL+V)in the terminal? I am totally surprised ;-) |
Oh really? Maybe something got fixed upstream. Thanks for the note @hgw77 😄 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days. |
Current workarounds:
On Firefox you can use middle-mouse click or shift+insert (possibly depends on your OS). Pasting with the right-click menu will not work on Firefox but you can press shift+right click to get the native context menu and use that to paste.
ctrl+v
will work in the editor but not the terminal.On Chrome
ctrl+shift+v
should work in the terminal andctrl+v
should work in the editor. If you use Chrome over a secure domain and accept the clipboard prompt then the right click menu to paste will work for the terminal but not the editor.Summary:
Currently only native paste or the clipboard API will work so there are certain cases where pasting will not work with the keybinding you'd expect (
ctrl+shift+v
in the terminal) or with the right-click menu (see my comments below for details).Original post:
Currently if you try to copy on an insecure domain you get "cannot read property
writeText
of undefined` because it's trying to access the clipboard which is undefined in insecure contexts.We could fall back to copying using
document.execCommand("copy")
which I think is what the editor does. That seems to work fine.For paste I believe the editor listens to the native
paste
command. That's not an option for the terminal because it requires we use the native keybinding (ctrl+v
) and that has a different function in the terminal.I've experimented with
document.execCommand("paste")
in the past but it didn't work so I assume this is why VS Code didn't use it here although perhaps more research is warranted here. That means our only option is the browser clipboard API which is only available in secure contexts.Having only copy but not paste available on the terminal doesn't seem like a good solution so I think our best bet is to detect when the context is insecure and display a message describing the need to use https.
Service workers don't work in an insecure context either so maybe it would be a good idea to display a message when the browser loads as well just so people are aware they're accessing code-server in an insecure way and that things might be broken (as well as just generally dangerous).
While we're at it we could also implement the editor paste command using the clipboard API which would resolve #1105.
The text was updated successfully, but these errors were encountered: