[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 ff35ac9dfa: Fix default-port regression in erc-select-read-args
From: |
F. Jason Park |
Subject: |
emacs-29 ff35ac9dfa: Fix default-port regression in erc-select-read-args |
Date: |
Mon, 2 Jan 2023 08:52:14 -0500 (EST) |
branch: emacs-29
commit ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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.)
---
lisp/erc/erc.el | 38 +++++++++++++++++++++++++++++---------
test/lisp/erc/erc-tests.el | 6 +++---
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index fe1201dd3a..6315d5aa48 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2161,6 +2161,23 @@ parameters SERVER and NICK."
(setq input (concat "irc://" 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
(defun erc-select-read-args ()
"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.
(url (url-generic-parse-url (erc--ensure-url input)))
(server (url-host url))
- (sp (and (or (string-suffix-p "s" (url-type url))
- (and (equal server erc-default-server)
- (not (string-prefix-p "irc://" input))))
- 'ircs-u))
+ (sp (and (string-suffix-p "s" (url-type url)) erc-default-port-tls))
(port (or (url-portspec url)
(erc-compute-port
(let ((d (erc-compute-port sp))) ; may be a string
@@ -2187,13 +2201,19 @@ parameters SERVER and NICK."
(let ((d (erc-compute-nick)))
(read-string (format "Nickname (default is %S): " d)
nil 'erc-nick-history-list d))))
- (passwd (or (url-password url)
- (if erc-prompt-for-password
- (read-passwd "Server password (optional): ")
- (with-suppressed-warnings ((obsolete erc-password))
- erc-password)))))
+ (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
+ (or (url-password url) erc-password)))
+ (m (if p
+ (format "Server password (default is %S): " p)
+ "Server password (optional): ")))
+ (if erc-prompt-for-password (read-passwd m nil p) p))))
(when (and passwd (string= "" passwd))
(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)))
;;;###autoload
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 6807b24bfc..85506c3d27 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1001,11 +1001,11 @@
(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"
(erc-select-read-args))
(list :server "irc.libera.chat"
- :port 6697
+ :port 6667
:nick (user-login-name)
:password nil))))
@@ -1036,7 +1036,7 @@
:password nil))))
(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))
(list :server "localhost"
:port 6667
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 ff35ac9dfa: Fix default-port regression in erc-select-read-args,
F. Jason Park <=