emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 1b1d387 2/2: Don't send empty lines for unknown commands in ERC


From: Lars Ingebrigtsen
Subject: master 1b1d387 2/2: Don't send empty lines for unknown commands in ERC
Date: Sat, 6 Nov 2021 14:13:41 -0400 (EDT)

branch: master
commit 1b1d387b96ebeb8330a76240db0cda6b8cefdf1f
Author: F. Jason Park <jp@neverwas.me>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Don't send empty lines for unknown commands in ERC
    
    * lisp/erc/erc.el (erc-cmd-default): prevent excess trailing newlines
    from being sent.
    
    * test/lisp/erc/erc-tests.el: Update `erc-process-input-line' test to
    check for excess line feeds with unknown commands.
---
 lisp/erc/erc.el            |  2 +-
 test/lisp/erc/erc-tests.el | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 9fa1736..8e2bb83 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -2965,7 +2965,7 @@ Commands for which no erc-cmd-xxx exists, are tunneled 
through
 this function.  LINE is sent to the server verbatim, and
 therefore has to contain the command itself as well."
   (erc-log (format "cmd: DEFAULT: %s" line))
-  (erc-server-send (substring line 1))
+  (erc-server-send (string-trim-right (substring line 1) "[\r\n]"))
   t)
 
 (defvar erc--read-time-period-history nil)
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 685f4e2..b2dbc10 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -236,6 +236,7 @@
   (let (erc-server-last-sent-time
         erc-server-flood-queue
         (orig-erc-cmd-MSG (symbol-function 'erc-cmd-MSG))
+        (erc-default-recipients '("#chan"))
         calls)
     (with-temp-buffer
       (cl-letf (((symbol-function 'erc-cmd-MSG)
@@ -247,9 +248,7 @@
                 ((symbol-function 'erc-server-process-alive)
                  (lambda () t))
                 ((symbol-function 'erc-server-send-queue)
-                 #'ignore)
-                ((symbol-function 'erc-default-target)
-                 (lambda () "" "#chan")))
+                 #'ignore))
 
         (ert-info ("Dispatch to user command handler")
 
@@ -259,6 +258,16 @@
             (should (equal (pop erc-server-flood-queue)
                            '("PRIVMSG #chan :hi\r\n" . utf-8))))
 
+          (ert-info ("Quote preserves line intact")
+            (erc-process-input-line "/QUOTE FAKE foo bar\n")
+            (should (equal (pop erc-server-flood-queue)
+                           '("FAKE foo bar\r\n" . utf-8))))
+
+          (ert-info ("Unknown command respected")
+            (erc-process-input-line "/FAKE foo bar\n")
+            (should (equal (pop erc-server-flood-queue)
+                           '("FAKE foo bar\r\n" . utf-8))))
+
           (ert-info ("Spaces preserved")
             (erc-process-input-line "/msg #chan hi you\n")
             (should (equal (pop calls) " #chan hi you"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]