Fix default-port regression in erc-select-read-args
* lisp/erc/erc.el (erc--warn-unencrypted): New function, likely temporary, to warn new users connecting interactively to the default server, "irc.libara.chat", via the default non-TLS port, 6667. (erc-select-read-args): Remove stray code from incomplete feature introduced by bug#56514. Ensure connecting always works with default port, which is non-TLS. Respect `erc-prompt-for-password' when user pastes URL containing password component into "server" prompt. Maybe add `erc--warn-unencrypted' as one-off hook for impending connection. * test/lisp/erc/erc-tests.el (erc-select-read-args): Always expect password prompt and sometimes a non-TLS port when `erc' called interactively. (Bug#60428.)
This commit is contained in:
parent
b7ad0b4014
commit
ff35ac9dfa
2 changed files with 32 additions and 12 deletions
|
@ -2161,6 +2161,23 @@ parameters SERVER and NICK."
|
||||||
(setq input (concat "irc://" input)))
|
(setq input (concat "irc://" input)))
|
||||||
input)
|
input)
|
||||||
|
|
||||||
|
;; A temporary means of addressing the problem of ERC's namesake entry
|
||||||
|
;; point defaulting to a non-TLS connection with its default server
|
||||||
|
;; (bug#60428).
|
||||||
|
(defun erc--warn-unencrypted ()
|
||||||
|
;; Remove unconditionally to avoid wrong context due to races from
|
||||||
|
;; simultaneous dialing or aborting (e.g., via `keybaord-quit').
|
||||||
|
(remove-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted)
|
||||||
|
(when (and (process-contact erc-server-process :nowait)
|
||||||
|
(equal erc-session-server erc-default-server)
|
||||||
|
(eql erc-session-port erc-default-port))
|
||||||
|
;; FIXME use the autoloaded `info' instead of `Info-goto-node' in
|
||||||
|
;; `erc-button-alist'.
|
||||||
|
(require 'info nil t)
|
||||||
|
(erc-display-error-notice
|
||||||
|
nil (concat "This connection is unencrypted. Please use `erc-tls'"
|
||||||
|
" from now on. See Info:\"(erc) connecting\" for more."))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun erc-select-read-args ()
|
(defun erc-select-read-args ()
|
||||||
"Prompt the user for values of nick, server, port, and password."
|
"Prompt the user for values of nick, server, port, and password."
|
||||||
|
@ -2171,10 +2188,7 @@ parameters SERVER and NICK."
|
||||||
;; For legacy reasons, also accept a URL without a scheme.
|
;; For legacy reasons, also accept a URL without a scheme.
|
||||||
(url (url-generic-parse-url (erc--ensure-url input)))
|
(url (url-generic-parse-url (erc--ensure-url input)))
|
||||||
(server (url-host url))
|
(server (url-host url))
|
||||||
(sp (and (or (string-suffix-p "s" (url-type url))
|
(sp (and (string-suffix-p "s" (url-type url)) erc-default-port-tls))
|
||||||
(and (equal server erc-default-server)
|
|
||||||
(not (string-prefix-p "irc://" input))))
|
|
||||||
'ircs-u))
|
|
||||||
(port (or (url-portspec url)
|
(port (or (url-portspec url)
|
||||||
(erc-compute-port
|
(erc-compute-port
|
||||||
(let ((d (erc-compute-port sp))) ; may be a string
|
(let ((d (erc-compute-port sp))) ; may be a string
|
||||||
|
@ -2187,13 +2201,19 @@ parameters SERVER and NICK."
|
||||||
(let ((d (erc-compute-nick)))
|
(let ((d (erc-compute-nick)))
|
||||||
(read-string (format "Nickname (default is %S): " d)
|
(read-string (format "Nickname (default is %S): " d)
|
||||||
nil 'erc-nick-history-list d))))
|
nil 'erc-nick-history-list d))))
|
||||||
(passwd (or (url-password url)
|
(passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
|
||||||
(if erc-prompt-for-password
|
(or (url-password url) erc-password)))
|
||||||
(read-passwd "Server password (optional): ")
|
(m (if p
|
||||||
(with-suppressed-warnings ((obsolete erc-password))
|
(format "Server password (default is %S): " p)
|
||||||
erc-password)))))
|
"Server password (optional): ")))
|
||||||
|
(if erc-prompt-for-password (read-passwd m nil p) p))))
|
||||||
(when (and passwd (string= "" passwd))
|
(when (and passwd (string= "" passwd))
|
||||||
(setq passwd nil))
|
(setq passwd nil))
|
||||||
|
(when (and (equal server erc-default-server)
|
||||||
|
(eql port erc-default-port)
|
||||||
|
(not (eql port erc-default-port-tls)) ; not `erc-tls'
|
||||||
|
(not (string-prefix-p "irc://" input))) ; not yanked URL
|
||||||
|
(add-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted))
|
||||||
(list :server server :port port :nick nick :password passwd)))
|
(list :server server :port port :nick nick :password passwd)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
|
@ -1001,11 +1001,11 @@
|
||||||
|
|
||||||
(ert-deftest erc-select-read-args ()
|
(ert-deftest erc-select-read-args ()
|
||||||
|
|
||||||
(ert-info ("Defaults to TLS")
|
(ert-info ("Does not default to TLS")
|
||||||
(should (equal (ert-simulate-keys "\r\r\r\r"
|
(should (equal (ert-simulate-keys "\r\r\r\r"
|
||||||
(erc-select-read-args))
|
(erc-select-read-args))
|
||||||
(list :server "irc.libera.chat"
|
(list :server "irc.libera.chat"
|
||||||
:port 6697
|
:port 6667
|
||||||
:nick (user-login-name)
|
:nick (user-login-name)
|
||||||
:password nil))))
|
:password nil))))
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@
|
||||||
:password nil))))
|
:password nil))))
|
||||||
|
|
||||||
(ert-info ("Address includes nick and password")
|
(ert-info ("Address includes nick and password")
|
||||||
(should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r"
|
(should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r\r"
|
||||||
(erc-select-read-args))
|
(erc-select-read-args))
|
||||||
(list :server "localhost"
|
(list :server "localhost"
|
||||||
:port 6667
|
:port 6667
|
||||||
|
|
Loading…
Add table
Reference in a new issue