unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12117: read-passwd deletes prompt
@ 2012-08-02  8:07 Juri Linkov
  2012-08-06 22:00 ` Stefan Monnier
  2012-08-15  4:03 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Juri Linkov @ 2012-08-02  8:07 UTC (permalink / raw)
  To: 12117

A new implementation of `read-passwd' allows the user to delete
characters from the minibuffer's prompt, i.e. when the user
mistypes the password and wants to retype it after clearing with
a few of DELs, typing more DEL will start removing characters
from the prompt.

This can be reproduced by visiting a GPG encrypted file that uses
`epa-passphrase-callback-function' that calls `read-passwd'.

The problem is that `find-file-noselect-1' binds `inhibit-read-only' to t
before calling `insert-file-contents':

            (let ((inhibit-read-only t))
              (insert-file-contents filename t))

The simplest test case to demonstrate the problem is to type DEL
after evaluating:

  (let ((inhibit-read-only t))
    (read-passwd "Password: "))

What is expected is: instead of deleting characters from the prompt
DEL should display the message "Text is read-only".

One solution is to let-bind `inhibit-read-only' to nil either
in `read-passwd' or in `epa-passphrase-callback-function',
or maybe in both?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12117: read-passwd deletes prompt
  2012-08-02  8:07 bug#12117: read-passwd deletes prompt Juri Linkov
@ 2012-08-06 22:00 ` Stefan Monnier
  2012-08-07  0:04   ` Juri Linkov
  2012-08-15  4:03 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2012-08-06 22:00 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12117

> The problem is that `find-file-noselect-1' binds `inhibit-read-only' to t
> before calling `insert-file-contents':

>             (let ((inhibit-read-only t))
>               (insert-file-contents filename t))

Hmm... I guess the problem is even more general: any minibuffer input
during insert-file-contents will suffer from it (granted, there usually
isn't much minibuffer input during such calls, luckily).

Maybe read-from-minibuffer should let-bind inhibit-read-only to nil?
That sounds ugly, tho.


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12117: read-passwd deletes prompt
  2012-08-06 22:00 ` Stefan Monnier
@ 2012-08-07  0:04   ` Juri Linkov
  2012-08-07 15:08     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2012-08-07  0:04 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 12117

> Hmm... I guess the problem is even more general: any minibuffer input
> during insert-file-contents will suffer from it (granted, there usually
> isn't much minibuffer input during such calls, luckily).
>
> Maybe read-from-minibuffer should let-bind inhibit-read-only to nil?
> That sounds ugly, tho.

Since there is not much minibuffer input during insert-file-contents
(one is known at the moment) then perhaps it would be safer to fix
just these places specific to insert-file-contents:

=== modified file 'lisp/epa.el'
--- lisp/epa.el	2012-06-08 16:39:49 +0000
+++ lisp/epa.el	2012-08-07 00:01:14 +0000
@@ -589,6 +589,10 @@ (defun epa-display-verify-result (verify
 (make-obsolete 'epa-display-verify-result 'epa-display-info "23.1")
 
 (defun epa-passphrase-callback-function (context key-id handback)
+  ;; Bind `inhibit-read-only' to nil because `find-file-noselect-1' binds
+  ;; it to t (for `insert-file-contents') that allows the user to delete
+  ;; characters in the read-only minibuffer prompt in `read-passwd'.
+  (let ((inhibit-read-only nil))
   (if (eq key-id 'SYM)
       (read-passwd
        (format "Passphrase for symmetric encryption%s: "
@@ -603,7 +607,7 @@ (defun epa-passphrase-callback-function
        (let ((entry (assoc key-id epg-user-id-alist)))
 	 (if entry
 	     (format "Passphrase for %s %s: " key-id (cdr entry))
-	   (format "Passphrase for %s: " key-id)))))))
+	     (format "Passphrase for %s: " key-id))))))))
 
 (defun epa-progress-callback-function (_context what _char current total
 					       handback)





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12117: read-passwd deletes prompt
  2012-08-07  0:04   ` Juri Linkov
@ 2012-08-07 15:08     ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2012-08-07 15:08 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12117

>> Hmm... I guess the problem is even more general: any minibuffer input
>> during insert-file-contents will suffer from it (granted, there usually
>> isn't much minibuffer input during such calls, luckily).
>> Maybe read-from-minibuffer should let-bind inhibit-read-only to nil?
>> That sounds ugly, tho.
> Since there is not much minibuffer input during insert-file-contents
> (one is known at the moment) then perhaps it would be safer to fix
> just these places specific to insert-file-contents:

No, I'd rather fix it in read-from-minibuffer than in just those
specific cases we bump into.

I think the "right" fix might be to make inhibit-read-only
buffer-local.  But I fear some code relies on it being global, so it
might introduce bugs.


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12117: read-passwd deletes prompt
  2012-08-02  8:07 bug#12117: read-passwd deletes prompt Juri Linkov
  2012-08-06 22:00 ` Stefan Monnier
@ 2012-08-15  4:03 ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2012-08-15  4:03 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12117-done

> One solution is to let-bind `inhibit-read-only' to nil either
> in `read-passwd' or in `epa-passphrase-callback-function',
> or maybe in both?

I've installed a patch which let-binds inhibit-read-only in
read-from-minibuffer.


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-15  4:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02  8:07 bug#12117: read-passwd deletes prompt Juri Linkov
2012-08-06 22:00 ` Stefan Monnier
2012-08-07  0:04   ` Juri Linkov
2012-08-07 15:08     ` Stefan Monnier
2012-08-15  4:03 ` Stefan Monnier

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).