New issue
Advanced search Search tips

Issue 737299 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

hterm: ctrl-v-paste logic assumes OS/browser will paste

Project Member Reported by vapier@chromium.org, Jun 27 2017

Issue description

the current ctrl-v keyboard callback assumes that the OS/browser itself normally pastes on that event.  so when we implement support for ctrl-v==paste or ctrl-shift-v==paste, we do so by returning hterm.Keyboard.KeyActions.PASS which allows the OS to do the paste.  this works for most platforms, but macOS has no default paste shortcut.  instead, it has cmd-v for pasting which means our ctrl-v/ctrl-shift-v logic does nothing.

easiest answer is probably to just always handle the paste event ourselves like we do with mouse pasting.

 hterm.Keyboard.KeyMap.prototype.onCtrlV_ = function(e, keyDef) {
   if ((!e.shiftKey && this.keyboard.ctrlVPaste) ||
       (e.shiftKey && !this.keyboard.ctrlVPaste)) {
-    return hterm.Keyboard.KeyActions.PASS;
+    this.keyboard.terminal.paste();
+    return hterm.Keyboard.KeyActions.CANCEL;
   }

   return '\x16';
 };

 
Project Member

Comment 1 by bugdroid1@chromium.org, Jun 29 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/apps/libapps/+/0091f9345341ce07616793a9fe9b14675993b4cd

commit 0091f9345341ce07616793a9fe9b14675993b4cd
Author: Mike Frysinger <vapier@chromium.org>
Date: Thu Jun 29 21:12:03 2017

hterm: handle ctrl-v/ctr-shift-v pasting ourselves

Since not all browsers/OS's binding Ctrl-V to paste (e.g. macOS only
binds Command+V), make our Ctrl-V handler do the pasting ourselves.
This way we get consistent behavior across all platforms.  If people
don't want Ctrl-V to paste, they can do their own keybinding:
	{
		"Ctrl-V": "PASS",
		"Ctrl-Shift-V": "PASS"
	}

BUG= chromium:737299 

Change-Id: I1213575c0e481f86c6323a4f2c67a06a778085a0
Reviewed-on: https://chromium-review.googlesource.com/551275
Reviewed-by: Brandon Gilmore <varz@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/0091f9345341ce07616793a9fe9b14675993b4cd/hterm/js/hterm_keyboard_keymap.js

Comment 2 by vapier@chromium.org, Jun 29 2017

Owner: vapier@chromium.org
Status: Fixed (was: Available)
this is fixed in hterm-1.66+ and nassh-0.8.36.6+
Project Member

Comment 3 by bugdroid1@chromium.org, Jul 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/apps/libapps/+/4628ad275e655a68848348bb393f15e3e380d8a1

commit 4628ad275e655a68848348bb393f15e3e380d8a1
Author: Mike Frysinger <vapier@chromium.org>
Date: Thu Jul 20 18:03:04 2017

hterm: restore native pasting as a fallback

In some environments (notably, "normal" websites), we don't have direct
access to read the clipboard (security!).  In those cases, our attempt
to directly paste ultimately fails breaking ctrl+v shortcuts.

Instead, let's plumb the return value of the paste command back up to
the callers so they can decide what mitigations to deploy.  For mouse
pasting, there's nothing we can do but whine.  For the keyboard, we can
fallback to letting the OS do its thing (and just hope for the best).

BUG= chromium:737299 

Change-Id: I00847cc6f13132b8486a7e6b850ec790afa8d2e5
Reviewed-on: https://chromium-review.googlesource.com/578849
Reviewed-by: Brandon Gilmore <varz@google.com>
Tested-by: Mike Frysinger <vapier@chromium.org>

[modify] https://crrev.com/4628ad275e655a68848348bb393f15e3e380d8a1/hterm/js/hterm_keyboard_keymap.js
[modify] https://crrev.com/4628ad275e655a68848348bb393f15e3e380d8a1/hterm/js/hterm_terminal.js
[modify] https://crrev.com/4628ad275e655a68848348bb393f15e3e380d8a1/hterm/js/hterm.js

Sign in to add a comment