unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Cc: 1104@emacsbugs.donarmstrong.com, jidanni@jidanni.org
Subject: Re: pasting a password
Date: Sun, 16 Nov 2008 01:01:21 -0500	[thread overview]
Message-ID: <87skpsw6oe.fsf@cyd.mit.edu> (raw)

> DW> Login Name: myname
>
> DW> Login Password: {SHA}reallylongsodontaskmetotypeitinbyhandplease
>
> DW> Login URL: http://wiki.debian.org/UserPreferences
>
> The problem is C-y is just read as a raw character there at the
> mini buffer Password: prompt. emacs-w3m-version "1.4.263".
>
> KY> That's what `read-passwd' that is an Emacs function does.  In
> KY> the function definition, the special keys that it handles are
> KY> only C-h, C-u and C-? (see the doc string).

The following patch allows yanking into the password prompt (I haven't
changed the docstring of read-passwd, which needs doing).  What do
people think about the advisability of this?

Note, in particular, that we can detect any key that performs yank or
yank-pop by using `key-binding'---but it works only if the command is a
single-character key sequence.  That's fine for C-y, but fails if the
user has customized `yank' to a two-character sequence.  I don't see any
way around this, though.

Another shortcoming is that the user can no longer enter a literal C-y;
but this may be a negligble problem---currently, the user can't enter
C-u either, since C-u clears the field.


*** trunk/lisp/subr.el.~1.620.~	2008-11-06 01:49:41.000000000 -0500
--- trunk/lisp/subr.el	2008-11-16 00:48:31.000000000 -0500
***************
*** 1818,1838 ****
  		      (setq c (read-char-exclusive nil t))
  		      (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
  	  (clear-this-command-keys)
! 	  (if (= c ?\C-u)
! 	      (progn
! 		(and (arrayp pass) (clear-string pass))
! 		(setq pass ""))
! 	    (if (and (/= c ?\b) (/= c ?\177))
! 		(let* ((new-char (char-to-string c))
! 		       (new-pass (concat pass new-char)))
! 		  (and (arrayp pass) (clear-string pass))
! 		  (clear-string new-char)
! 		  (setq c ?\0)
! 		  (setq pass new-pass))
! 	      (if (> (length pass) 0)
! 		  (let ((new-pass (substring pass 0 -1)))
! 		    (and (arrayp pass) (clear-string pass))
! 		    (setq pass new-pass))))))
  	(message nil)
  	(or pass default "")))))
  
--- 1818,1845 ----
  		      (setq c (read-char-exclusive nil t))
  		      (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
  	  (clear-this-command-keys)
! 	  (cond ((= c ?\C-u)
! 		 (and (arrayp pass) (clear-string pass))
! 		 (setq pass ""))
! 		((memq (key-binding (vector c))
! 		       '(yank yank-pop))
! 		 (let ((new-pass (concat pass
! 					 (substring-no-properties
! 					  (current-kill 0)))))
! 		   (and (arrayp pass) (clear-string pass))
! 		   (setq c ?\0)
! 		   (setq pass new-pass)))
! 		((and (/= c ?\b) (/= c ?\177))
! 		 (let* ((new-char (char-to-string c))
! 			(new-pass (concat pass new-char)))
! 		   (and (arrayp pass) (clear-string pass))
! 		   (clear-string new-char)
! 		   (setq c ?\0)
! 		   (setq pass new-pass)))
! 		((> (length pass) 0)
! 		 (let ((new-pass (substring pass 0 -1)))
! 		   (and (arrayp pass) (clear-string pass))
! 		   (setq pass new-pass)))))
  	(message nil)
  	(or pass default "")))))
  

Diff finished.  Sun Nov 16 00:51:53 2008




             reply	other threads:[~2008-11-16  6:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-16  6:01 Chong Yidong [this message]
2008-11-16  8:38 ` pasting a password Andreas Schwab
2008-11-16 16:08   ` Chong Yidong
2008-11-16 19:21   ` Stefan Monnier
2008-11-16 20:55     ` jidanni
2008-11-16 21:07       ` Chong Yidong
2008-11-16 23:10         ` Stefan Monnier
2008-11-16 23:37           ` Chong Yidong
2008-11-16 22:25     ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87skpsw6oe.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=1104@emacsbugs.donarmstrong.com \
    --cc=emacs-devel@gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).