diff options
Diffstat (limited to 'lisp/net/rcirc.el')
-rw-r--r-- | lisp/net/rcirc.el | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 8926772b944..24084c828e1 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -774,22 +774,33 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.") (rcirc-process-server-response-1 process text))) (defun rcirc-process-server-response-1 (process text) - (if (string-match "^\\(:\\([^ ]+\\) \\)?\\([^ ]+\\) \\(.+\\)$" text) + ;; See https://tools.ietf.org/html/rfc2812#section-2.3.1. We're a + ;; bit more accepting than the RFC: We allow any non-space + ;; characters in the command name, multiple spaces between + ;; arguments, and allow the last argument to omit the leading ":", + ;; even if there are less than 15 arguments. + (if (string-match "^\\(:\\([^ ]+\\) \\)?\\([^ ]+\\)" text) (let* ((user (match-string 2 text)) (sender (rcirc-user-nick user)) (cmd (match-string 3 text)) - (args (match-string 4 text)) + (cmd-end (match-end 3)) + (args nil) (handler (intern-soft (concat "rcirc-handler-" cmd)))) - (string-match "^\\([^:]*\\):?\\(.+\\)?$" args) - (let* ((args1 (match-string 1 args)) - (args2 (match-string 2 args)) - (args (delq nil (append (split-string args1 " " t) - (list args2))))) + (cl-loop with i = cmd-end + repeat 14 + while (eql i (string-match " +\\([^: ][^ ]*\\)" text i)) + do (progn (push (match-string 1 text) args) + (setq i (match-end 0))) + finally + (progn (if (eql i (string-match " +:?" text i)) + (push (substring text (match-end 0)) args) + (cl-assert (= i (length text)))) + (cl-callf nreverse args))) (if (not (fboundp handler)) (rcirc-handler-generic process cmd sender args text) (funcall handler process sender args text)) (run-hook-with-args 'rcirc-receive-message-functions - process cmd sender args text))) + process cmd sender args text)) (message "UNHANDLED: %s" text))) (defvar rcirc-responses-no-activity '("305" "306") |