aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2022-12-29 06:43:19 -0800
committerF. Jason Park2023-01-02 05:48:39 -0800
commitff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4 (patch)
treed9b8e9a8f20a71ab86dfef976da05ea92bb5739b
parentb7ad0b40148bd5905497a4c05fced4e0b9099812 (diff)
downloademacs-ff35ac9dfabf7ac33199c42bc56c8bb0f53eebc4.tar.gz
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.)
-rw-r--r--lisp/erc/erc.el38
-rw-r--r--test/lisp/erc/erc-tests.el6
2 files changed, 32 insertions, 12 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."
2161 (setq input (concat "irc://" input))) 2161 (setq input (concat "irc://" input)))
2162 input) 2162 input)
2163 2163
2164;; A temporary means of addressing the problem of ERC's namesake entry
2165;; point defaulting to a non-TLS connection with its default server
2166;; (bug#60428).
2167(defun erc--warn-unencrypted ()
2168 ;; Remove unconditionally to avoid wrong context due to races from
2169 ;; simultaneous dialing or aborting (e.g., via `keybaord-quit').
2170 (remove-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted)
2171 (when (and (process-contact erc-server-process :nowait)
2172 (equal erc-session-server erc-default-server)
2173 (eql erc-session-port erc-default-port))
2174 ;; FIXME use the autoloaded `info' instead of `Info-goto-node' in
2175 ;; `erc-button-alist'.
2176 (require 'info nil t)
2177 (erc-display-error-notice
2178 nil (concat "This connection is unencrypted. Please use `erc-tls'"
2179 " from now on. See Info:\"(erc) connecting\" for more."))))
2180
2164;;;###autoload 2181;;;###autoload
2165(defun erc-select-read-args () 2182(defun erc-select-read-args ()
2166 "Prompt the user for values of nick, server, port, and password." 2183 "Prompt the user for values of nick, server, port, and password."
@@ -2171,10 +2188,7 @@ parameters SERVER and NICK."
2171 ;; For legacy reasons, also accept a URL without a scheme. 2188 ;; For legacy reasons, also accept a URL without a scheme.
2172 (url (url-generic-parse-url (erc--ensure-url input))) 2189 (url (url-generic-parse-url (erc--ensure-url input)))
2173 (server (url-host url)) 2190 (server (url-host url))
2174 (sp (and (or (string-suffix-p "s" (url-type url)) 2191 (sp (and (string-suffix-p "s" (url-type url)) erc-default-port-tls))
2175 (and (equal server erc-default-server)
2176 (not (string-prefix-p "irc://" input))))
2177 'ircs-u))
2178 (port (or (url-portspec url) 2192 (port (or (url-portspec url)
2179 (erc-compute-port 2193 (erc-compute-port
2180 (let ((d (erc-compute-port sp))) ; may be a string 2194 (let ((d (erc-compute-port sp))) ; may be a string
@@ -2187,13 +2201,19 @@ parameters SERVER and NICK."
2187 (let ((d (erc-compute-nick))) 2201 (let ((d (erc-compute-nick)))
2188 (read-string (format "Nickname (default is %S): " d) 2202 (read-string (format "Nickname (default is %S): " d)
2189 nil 'erc-nick-history-list d)))) 2203 nil 'erc-nick-history-list d))))
2190 (passwd (or (url-password url) 2204 (passwd (let* ((p (with-suppressed-warnings ((obsolete erc-password))
2191 (if erc-prompt-for-password 2205 (or (url-password url) erc-password)))
2192 (read-passwd "Server password (optional): ") 2206 (m (if p
2193 (with-suppressed-warnings ((obsolete erc-password)) 2207 (format "Server password (default is %S): " p)
2194 erc-password))))) 2208 "Server password (optional): ")))
2209 (if erc-prompt-for-password (read-passwd m nil p) p))))
2195 (when (and passwd (string= "" passwd)) 2210 (when (and passwd (string= "" passwd))
2196 (setq passwd nil)) 2211 (setq passwd nil))
2212 (when (and (equal server erc-default-server)
2213 (eql port erc-default-port)
2214 (not (eql port erc-default-port-tls)) ; not `erc-tls'
2215 (not (string-prefix-p "irc://" input))) ; not yanked URL
2216 (add-hook 'erc--server-post-connect-hook #'erc--warn-unencrypted))
2197 (list :server server :port port :nick nick :password passwd))) 2217 (list :server server :port port :nick nick :password passwd)))
2198 2218
2199;;;###autoload 2219;;;###autoload
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 6807b24bfc6..85506c3d27e 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1001,11 +1001,11 @@
1001 1001
1002(ert-deftest erc-select-read-args () 1002(ert-deftest erc-select-read-args ()
1003 1003
1004 (ert-info ("Defaults to TLS") 1004 (ert-info ("Does not default to TLS")
1005 (should (equal (ert-simulate-keys "\r\r\r\r" 1005 (should (equal (ert-simulate-keys "\r\r\r\r"
1006 (erc-select-read-args)) 1006 (erc-select-read-args))
1007 (list :server "irc.libera.chat" 1007 (list :server "irc.libera.chat"
1008 :port 6697 1008 :port 6667
1009 :nick (user-login-name) 1009 :nick (user-login-name)
1010 :password nil)))) 1010 :password nil))))
1011 1011
@@ -1036,7 +1036,7 @@
1036 :password nil)))) 1036 :password nil))))
1037 1037
1038 (ert-info ("Address includes nick and password") 1038 (ert-info ("Address includes nick and password")
1039 (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r" 1039 (should (equal (ert-simulate-keys "nick:sesame@localhost:6667\r\r"
1040 (erc-select-read-args)) 1040 (erc-select-read-args))
1041 (list :server "localhost" 1041 (list :server "localhost"
1042 :port 6667 1042 :port 6667