diff options
author | F. Jason Park <jp@neverwas.me> | 2023-04-17 23:09:49 -0700 |
---|---|---|
committer | F. Jason Park <jp@neverwas.me> | 2023-05-05 17:18:01 -0700 |
commit | 16306567706c9621cef169d0e992b9b3b08a9d7e (patch) | |
tree | c86256e93d2da9cfe9328fa16d35130831ac3345 /test | |
parent | b0d761be0f9b0180566d7cde1ef2eea33402dd4e (diff) | |
download | emacs-16306567706c9621cef169d0e992b9b3b08a9d7e.tar.gz |
Don't send multiline commands as messages in ERC
* lisp/erc/erc.el (erc-command-regexp): Relocate from further down in
same file.
(erc--check-prompt-input-for-multiline-command): Reject slash commands
containing multiple lines during input validation and before running
additional hooks.
(erc--discard-trailing-multiline-nulls): Don't mark input that begins
with a possible "slash command" as constituting a plain message just
because it has a trailing newline. It's relatively easy to add a
newline by accident, which can result in the unintended sharing of a
command line. Also, ERC already has a /SAY command that allows a user
to send a message starting a literal command.
* test/lisp/erc/erc-tests.el (erc-send-whitespace-lines): Fix test to
expect validation error when non-blank lines follow a slash command.
(Bug#62947)
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/erc/erc-tests.el | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index bafe418f0cd..4725d289e5b 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -1236,15 +1236,23 @@ (pcase-dolist (`(,p . ,q) '(("/a b\r" "/a b\n") ("/a b\n" "/a b\n") ("/a b\n\n" "/a b\n") ("/a b\r\n" "/a b\n") - ("a b\nc\n\n" "c\n" "a b\n") - ("/a b\nc\n\n" "c\n" "/a b\n") - ("/a b\n\nc\n\n" "c\n" "\n" "/a b\n"))) + ("/a b\n\n\n" "/a b\n"))) (insert p) (erc-send-current-line) (erc-bol) (should (eq (point) (point-max))) (while q - (should (equal (funcall next) (list (pop q) nil t)))) + (should (pcase (funcall next) + (`(,cmd ,_ nil) (equal cmd (pop q)))))) + (should-not (funcall next)))) + + (ert-info ("Multiline command with non-blanks errors") + (dolist (p '("/a b\nc\n\n" "/a b\n/c\n\n" "/a b\n\nc\n\n" + "/a\n c\n" "/a\nb\n" "/a\n/b\n" "/a \n \n")) + (insert p) + (should-error (erc-send-current-line)) + (goto-char erc-input-marker) + (delete-region (point) (point-max)) (should-not (funcall next)))) (ert-info ("Multiline hunk with trailing whitespace not filtered") |