summaryrefslogtreecommitdiff
path: root/lisp/erc
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2022-12-29 06:43:19 -0800
committerF. Jason Park <jp@neverwas.me>2023-01-02 05:48:39 -0800
commitff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4 (patch)
treed9b8e9a8f20a71ab86dfef976da05ea92bb5739b /lisp/erc
parentb7ad0b40148bd5905497a4c05fced4e0b9099812 (diff)
downloademacs-ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4.tar.gz
emacs-ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4.tar.bz2
emacs-ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4.zip
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.)
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/erc.el38
1 files changed, 29 insertions, 9 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index fe1201dd3a8..6315d5aa482 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