diff options
| author | F. Jason Park <jp@neverwas.me> | 2025-11-28 16:21:57 -0800 |
|---|---|---|
| committer | F. Jason Park <jp@neverwas.me> | 2026-05-12 21:03:02 -0700 |
| commit | 76f5181bc6af50dd7eab6deb75d83fd8e83e50e4 (patch) | |
| tree | fa77d2cc7ffcde241fa59606cc424e5de3902198 /test | |
| parent | aa316285846b4758c57deea13214dd87f41334da (diff) | |
Improve source NUH handling in ERC
* lisp/erc/erc.el (erc--user-nuh-message-types): New variable.
(erc--shuffle-nuh-nickward, erc--interpret-nuh): Replace former with
latter, whose behavior is easier to predict.
* test/lisp/erc/erc-tests.el (erc--interpret-nuh): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 3900f5d4880..35997a83de1 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -674,6 +674,39 @@ ;; No fallback behavior. (should-not (erc--parse-nuh "abc\nde!fg@xy"))) +;; NUH interpretation rules: +;; +;; 1. "a@b" or "a!b" - "a" is the nick and "b" is the host. Can't have +;; a login without a nick and a host. +;; +;; 2. "a" - either a nick or a host, depending on message type. The +;; presence of a "." does not imply a host because some IRC-adjacent +;; bridges allow nicks to contain dots, and a host can be a host +;; name, like "localhost" without a domain structure. Nick-only +;; types include PRIVMSG, JOIN, PART, QUIT, NICK, KICK, TOPIC, AWAY, +;; ACCOUNT, and TAGMSG. MODE can be either but is usually a nick +;; unless recovering from a netsplit or as a response to a ChanServ +;; OP. NOTICE can be either but is always a nick when directed to a +;; channel. +;; +;; 3. "a!", "a!@", "a@", "!a@", "@a", etc. are pathological. +;; +(ert-deftest erc--interpret-nuh () + (should (equal (erc--interpret-nuh (erc--parse-nuh "a@b")) + '("a" nil "b"))) + (should (equal (erc--interpret-nuh (erc--parse-nuh "a!b")) + '("a" nil "b"))) + (should (equal (erc--interpret-nuh (erc--parse-nuh "B..o..b")) + '("B..o..b" nil nil))) + (should (equal (erc--interpret-nuh (erc--parse-nuh "gnu.org")) + '("gnu.org" nil nil))) + (should (equal (erc--interpret-nuh (erc--parse-nuh "localhost")) + '("localhost" nil nil))) + + ;; Reject login containing CHANTYPE chars. + (should (equal (erc--parse-nuh "a&b@c") '(nil "a&b" "c"))) + (should-error (erc--interpret-nuh '(nil "a&b" "c")))) + (ert-deftest erc--parsed-prefix () ;; Effectively a no-op in a non-ERC buffer. (should-not (erc--parsed-prefix)) |
