summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2022-03-21 19:21:57 -0700
committerF. Jason Park <jp@neverwas.me>2022-06-30 15:19:53 -0700
commita9d89d083ac5bf0b9fd5568d42e565aba0b6e13f (patch)
tree90819c90c517a0a23c4428ba48cc884df58bc8ce
parent05902243431c877011a0bf6ce38c9230d0ef0721 (diff)
downloademacs-a9d89d083ac5bf0b9fd5568d42e565aba0b6e13f.tar.gz
Fix regression in erc-send-input-line
* lisp/erc/erc.el (erc-send-input-line): Restore remedial single-space padding to ensure empty messages typed at the prompt without an explicit /msg aren't rejected by the server. This behavior is only noticeable when `erc-send-whitespace-lines' is active. * test/lisp/erc/erc-tests.el (erc-process-input-line): Add trailing newline to more correctly simulate how it's actually called by `erc-send-input'. (Bug#50008)
-rw-r--r--lisp/erc/erc.el2
-rw-r--r--test/lisp/erc/erc-tests.el10
2 files changed, 7 insertions, 5 deletions
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 1c221a9cb13..971d3f426fc 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2992,6 +2992,8 @@ for special purposes (see erc-dcc.el).")
(defun erc-send-input-line (target line &optional force)
"Send LINE to TARGET."
+ (when (string= line "\n")
+ (setq line " \n"))
(erc-message "PRIVMSG" (concat target " " line) force))
(defun erc-get-arglist (fun)
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 618d7eeea02..afe9cc7b8cb 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -643,19 +643,19 @@
(ert-info ("Implicit cmd via `erc-send-input-line-function'")
(ert-info ("Baseline")
- (erc-process-input-line "hi")
+ (erc-process-input-line "hi\n")
(should (equal (pop erc-server-flood-queue)
'("PRIVMSG #chan :hi\r\n" . utf-8))))
(ert-info ("Spaces preserved")
- (erc-process-input-line "hi you")
+ (erc-process-input-line "hi you\n")
(should (equal (pop erc-server-flood-queue)
'("PRIVMSG #chan :hi you\r\n" . utf-8))))
- (ert-info ("Empty line transmitted without injected-space kludge")
- (erc-process-input-line "")
+ (ert-info ("Empty line transmitted with injected-space kludge")
+ (erc-process-input-line "\n")
(should (equal (pop erc-server-flood-queue)
- '("PRIVMSG #chan :\r\n" . utf-8))))
+ '("PRIVMSG #chan : \r\n" . utf-8))))
(should-not calls))))))