bug#46609: Fix shell password prompt in minibuffer (bug 43302)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#46609: Fix shell password prompt in minibuffer (bug 43302)

Lars Ingebrigtsen
Ryan Prior <[hidden email]> writes:

> The current comint-password-prompt-regexp does not tolerate newlines at
> the end of the prompt, so a string like "Password:\n" will not be
> recognized as a password prompt in shell-mode. Before Emacs 27
> (74277b0e881) newlines were tolerated here, so this is a regression, and
> as a result I would sometimes echo my password in plain text where
> previously it would be hidden.

Thanks; applied to Emacs 27 with one change:

> +    (when (string-match "[\n]+$" string)
> +      (setq string (replace-match "" t t string)))

This should probably be "\n+\\'", because we only want to remove
newlines from the end of the string, and not newlines from the middle of
the string, presumably?  ("$" means "match end of line", not "match end
of string".)

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#46609: Fix shell password prompt in minibuffer (bug 43302)

Andreas Schwab-2
On Feb 18 2021, Lars Ingebrigtsen wrote:

> Ryan Prior <[hidden email]> writes:
>
>> The current comint-password-prompt-regexp does not tolerate newlines at
>> the end of the prompt, so a string like "Password:\n" will not be
>> recognized as a password prompt in shell-mode. Before Emacs 27
>> (74277b0e881) newlines were tolerated here, so this is a regression, and
>> as a result I would sometimes echo my password in plain text where
>> previously it would be hidden.
>
> Thanks; applied to Emacs 27 with one change:
>
>> +    (when (string-match "[\n]+$" string)
>> +      (setq string (replace-match "" t t string)))
>
> This should probably be "\n+\\'", because we only want to remove
> newlines from the end of the string, and not newlines from the middle of
> the string, presumably?  ("$" means "match end of line", not "match end
> of string".)

The preceding line should probably use "\\`" as well.

Andreas.

--
Andreas Schwab, [hidden email]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



Reply | Threaded
Open this post in threaded view
|

bug#46609: Fix shell password prompt in minibuffer (bug 43302)

Lars Ingebrigtsen
Andreas Schwab <[hidden email]> writes:

> The preceding line should probably use "\\`" as well.

Yup, but that's not a regression, I think?  So it wouldn't be
appropriate to fix on the emacs-27 branch.  But we should fix it in
Emacs 28.

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



Reply | Threaded
Open this post in threaded view
|

bug#46609: Fix shell password prompt in minibuffer (bug 43302)

Eli Zaretskii
In reply to this post by Lars Ingebrigtsen
> From: Lars Ingebrigtsen <[hidden email]>
> Date: Thu, 18 Feb 2021 12:44:32 +0100
> Cc: [hidden email]
>
> Thanks; applied to Emacs 27 with one change:
>
> > +    (when (string-match "[\n]+$" string)
> > +      (setq string (replace-match "" t t string)))
>
> This should probably be "\n+\\'", because we only want to remove
> newlines from the end of the string, and not newlines from the middle of
> the string, presumably?  ("$" means "match end of line", not "match end
> of string".)

Do we want to remove more than one newline?



Reply | Threaded
Open this post in threaded view
|

bug#46609: Fix shell password prompt in minibuffer (bug 43302)

Lars Ingebrigtsen
Eli Zaretskii <[hidden email]> writes:

>> > +    (when (string-match "[\n]+$" string)
>> > +      (setq string (replace-match "" t t string)))
>>
>> This should probably be "\n+\\'", because we only want to remove
>> newlines from the end of the string, and not newlines from the middle of
>> the string, presumably?  ("$" means "match end of line", not "match end
>> of string".)
>
> Do we want to remove more than one newline?

It's just used as the prompt for a `read-string' call, so I think so?
Having a prompt end with a newline is just confusing.

(This (and the preceding two lines) should just be rewritten to use
`string-trim'.)

--
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no