Subject: bug#69010: 29.2.50; rcirc-process-regexp doesn't handle the "draft" prefix

From: Philip Kaludercic <[email-masked]>
Date: Sat, 10 Feb 2024 17:15:32 +0000

Istvan Marko <[email-masked]> writes:

> According to https://ircv3.net/specs/extensions/message-tags "draft" is
> a valid vendor prefix in IRC v3 message tags. rcirc-process-regexp
> currently doesn't handle this because it expects a period in the vendor
> prefix. With the current regexp when we encounter a message with a
> "draft/..." tag the entire tag sequence ends up in the "cmd" portion of
> the match and gets printed verbatim into the server buffer by
> rcirc-handle-generic.
>
> To avoid this accidental behavior I think rcirc should be prepared for
> the "draft" case even if it doesn't intend to handle draft tags:
>
> diff --git lisp/net/rcirc.el lisp/net/rcirc.el
> index 4f536071003..ab88a468b0f 100644
> --- lisp/net/rcirc.el
> +++ lisp/net/rcirc.el
> @@ -1014,7 +1014,7 @@ rcirc-process-regexp
>    (rx-let ((message-tag ; message tags as specified in
>                                          ; https://ircv3.net/specs/extensions/message-tags
>              (: (? "+")
> -               (? (+ (or alnum "-")) (+ "." (+ (or alnum "-"))) "/")
> +               (? (or "draft" (: (+ (or alnum "-")) (+ "." (+ (or alnum "-"))))) "/")
                                                        ^
                                                        (0)
                                                        
Instead of hard-coding "draft", would there be an issue with replacing
(0) with `zero-or-more'?

>                 (+ (any alnum "-"))
>                 (? "="
>                    (* (not (any 0 ?\n ?\r ?\; ?\s)))))))
>
> I believe this bug may also lead to losing messages in some situations
> and it prevents users from adding their own handlers for draft tags.
>
>
> In GNU Emacs 29.2.50 (build 2, x86_64-pc-linux-gnu) of 2024-01-21 built
>  on localhost
> Repository revision: c450eec07ff19953c8e1e75e99909d140db0e5d0
> Repository branch: emacs-29
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
> System Description: Gentoo Linux
>
> Configured using:
>  'configure --without-x-toolkit --without-gpm --without-rsvg
>  --without-gconf --without-xim --without-gsettings
>  --with-file-notification=inotify --without-lcms2 --with-modules
>  --without-cairo --without-native-compilation --without-xinput2'
>
> Configured features:
> ACL DBUS FREETYPE GIF GMP GNUTLS HARFBUZZ JPEG JSON LIBXML2 MODULES
> NOTIFY INOTIFY OLDXMENU PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS TIFF
> TREE_SITTER WEBP X11 XDBE XFT XIM XPM ZLIB
>
> Important settings:
>   value of $LANG: C
>   locale-coding-system: nil
>
> Major mode: ELisp/l
>
> Minor modes in effect:
>   bug-reference-prog-mode: t
>   server-mode: t
>   keyfreq-autosave-mode: t
>   keyfreq-mode: t
>   savehist-mode: t
>   iswitchb-mode: t
>   dired-async-mode: t
>   shell-dirtrack-mode: t
>   rcirc-track-minor-mode: t
>   display-time-mode: t
>   winner-mode: t
>   pdfgrep-mode: t
>   pdf-occur-global-minor-mode: t
>   global-atomic-chrome-edit-mode: t
>   override-global-mode: t
>   eldoc-mode: t
>   show-paren-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   line-number-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>
> Load-path shadows:
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-hello hides /usr/local/share/emacs/site-lisp/notmuch-hello
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-query hides /usr/local/share/emacs/site-lisp/notmuch-query
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-parser hides /usr/local/share/emacs/site-lisp/notmuch-parser
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-tag hides /usr/local/share/emacs/site-lisp/notmuch-tag
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-tree hides /usr/local/share/emacs/site-lisp/notmuch-tree
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-print hides /usr/local/share/emacs/site-lisp/notmuch-print
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/coolj hides /usr/local/share/emacs/site-lisp/coolj
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-lib hides /usr/local/share/emacs/site-lisp/notmuch-lib
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-wash hides /usr/local/share/emacs/site-lisp/notmuch-wash
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-message hides /usr/local/share/emacs/site-lisp/notmuch-message
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-crypto hides /usr/local/share/emacs/site-lisp/notmuch-crypto
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-jump hides /usr/local/share/emacs/site-lisp/notmuch-jump
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-draft hides /usr/local/share/emacs/site-lisp/notmuch-draft
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-mua hides /usr/local/share/emacs/site-lisp/notmuch-mua
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-show hides /usr/local/share/emacs/site-lisp/notmuch-show
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-compat hides /usr/local/share/emacs/site-lisp/notmuch-compat
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch hides /usr/local/share/emacs/site-lisp/notmuch
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-company hides /usr/local/share/emacs/site-lisp/notmuch-company
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-address hides /usr/local/share/emacs/site-lisp/notmuch-address
> /home/mi/.emacs.d/elpa/notmuch-20231006.2337/notmuch-maildir-fcc hides /usr/local/share/emacs/site-lisp/notmuch-maildir-fcc
> /home/mi/.emacs.d/elpa/eglot-20221020.1010/eglot hides /usr/local/share/emacs/29.2.50/lisp/progmodes/eglot
>
> Features:
> (shadow sort mail-extr emacsbug bug-reference regex-tool
> regex-tool-autoloads display-line-numbers mastodon-notifications cus-dep
> cus-theme descr-text qrencode qrencode-autoloads loaddefs-gen mm-archive
> man rst generic proced macrostep-c cmacexp calc-alg calc-ext dictionary
> dictionary-connection python dirtrack sgml-mode quail mastodon-media
> mastodon-profile url-http url-gw url-cache url-auth mastodon-auth
> mastodon-client plstore mastodon-tl mastodon mastodon-search
> mastodon-toot lingva mastodon-iso persist emojify apropos tar-mode
> arc-mode archive-mode ht mastodon-http request shortdoc calc-menu calc
> calc-loaddefs rect calc-macs counsel swiper ivy ivy-faces ivy-overlay
> colir emms-volume emms-volume-sndioctl emms-volume-mixerctl
> emms-volume-pulse emms-volume-amixer emms-playlist-mode
> emms-source-playlist emms-source-file locate pdf-sync pdf-annot facemenu
> pdf-outline pdf-links pdf-history cal-move dcl-mode term/tmux tramp-cmds
> oc-basic org-element org-persist org-id org-refile avl-tree ol-eww
> ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-art mm-uu mml2015
> gnus-sum gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud
> nnimap nnmail mail-source utf7 nnoo gnus-spec gnus-int gnus-range
> gnus-win ol-docview doc-view ol-bibtex bibtex ol-bbdb ol-w3m ol-doi
> org-link-doi vc-filewise vc-rcs log-view vc-hg conf-mode tramp-cache
> time-stamp markdown-mode view smerge-mode diff diminish jinx log-edit
> pcvs-util add-log vc cl-print vc-git vc-dispatcher rcirc-styles textsec
> uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check
> dabbrev tabify cus-start help-fns radix-tree misearch multi-isearch
> mule-util network-stream nsm my-exwm exwm-randr xcb-randr exwm
> exwm-input xcb-keysyms xcb-xkb exwm-manage exwm-floating xcb-cursor
> xcb-render exwm-layout exwm-workspace exwm-core xcb-ewmh xcb-icccm xcb
> xcb-xproto xcb-types xcb-debug dim pinentry free-keys my-osc52 my-utils
> pass f password-store auth-source-pass with-editor server compat unfill
> keyfreq hydra lv yasnippet idle-display ob-restclient restclient
> sqlite-dump emms emms-compat my-notmuch notmuch notmuch-tree
> notmuch-jump notmuch-hello notmuch-show notmuch-print notmuch-crypto
> notmuch-mua notmuch-message notmuch-draft notmuch-maildir-fcc
> notmuch-address notmuch-company notmuch-parser notmuch-wash diff-mode
> coolj goto-addr icalendar notmuch-tag crm notmuch-lib notmuch-version
> notmuch-compat hl-line mm-view mml-smime smime gnutls dig org-tempo org
> ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint
> org-pcomplete org-list org-footnote org-faces org-entities ob-emacs-lisp
> ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys
> oc org-loaddefs org-compat tempo org-version org-macs uptimes savehist
> iswitchb dired-duplicates dired-open dired-hacks-utils wdired dired-x
> dired-async dired-aux async vterm face-remap color term disp-table ehelp
> vterm-module term/xterm xterm vterm-toggle tramp-sh tramp tramp-loaddefs
> trampver tramp-integration files-x tramp-compat shell pcomplete
> my-mastodon my-rcirc rcirc parse-time iso8601 time cal-china lunar solar
> cal-dst holidays holiday-loaddefs appt diary-lib diary-loaddefs cal-menu
> calendar cal-loaddefs generic-x bracketed-paste cl auto-capitalize
> message yank-media rfc822 mml mml-sec epa derived epg rfc6068 epg-config
> mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
> mailheader smtpmail-multi smtpmail sendmail rfc2047 rfc2045 ietf-drums
> winner mouse-drag terraform-mode noutline outline hcl-mode
> graphviz-dot-mode pdfgrep pdf-occur tablist tablist-filter
> semantic/wisent/comp semantic/wisent semantic/wisent/wisent
> semantic/util-modes semantic/util semantic semantic/tag semantic/lex
> semantic/fw mode-local cedet pdf-isearch pdf-misc pdf-tools cus-edit
> cus-load pdf-view bookmark jka-compr pdf-cache pdf-info tq pdf-util
> format-spec pdf-macs image-mode dired dired-loaddefs exif dumb-jump
> popup dash s eglot array filenotify jsonrpc ert ewoc debug backtrace
> find-func flymake-proc flymake warnings icons projectile lisp-mnt grep
> ibuf-ext ibuffer ibuffer-loaddefs prettier-js git-auto-commit-mode
> eww-lnum my-eww eww xdg url-queue shr pixel-fill kinsoku url-file svg
> xml dom puny mm-url gnus nnheader gnus-util time-date mail-utils range
> wid-edit mm-util mail-prsvr browse-kill-ring delsel advice atomic-chrome
> websocket bindat let-alist dockerfile-mode sh-script smie executable
> json-mode json-snatcher js c-ts-common treesit imenu align glsl-mode
> protobuf-mode cc-mode cc-fonts cc-guess cc-menus cc-styles cc-align
> kotlin-mode kotlin-mode-indent kotlin-mode-lexer cc-cmds cc-engine
> cc-vars cc-defs rust-utils rust-mode rust-rustfmt rust-playpen
> rust-compile rust-cargo go-rename go-guru go-mode find-file ffap
> thingatpt etags fileloop generator xref project compile
> text-property-search comint ansi-osc ansi-color edmacro kmacro macrostep
> ring pp keydef cl-extra help-mode use-package use-package-ensure
> use-package-delight use-package-diminish use-package-bind-key bind-key
> easy-mmode use-package-core ag-autoloads anaphora-autoloads
> ascii-art-to-unicode-autoloads async-autoloads atomic-chrome-autoloads
> avy-autoloads bracketed-paste-autoloads browse-at-remote-autoloads
> browse-kill-ring-autoloads caddyfile-mode-autoloads
> clojure-mode-autoloads counsel-autoloads counsel-notmuch-autoloads
> csv-mode-autoloads dart-mode-autoloads diminish-autoloads
> dired-duplicates-autoloads dired-open-autoloads dired-subtree-autoloads
> dired-hacks-utils-autoloads dockerfile-mode-autoloads
> dumb-jump-autoloads eat-autoloads elixir-mode-autoloads elpher-autoloads
> emms-autoloads emojify-autoloads eww-lnum-autoloads exwm-autoloads
> fennel-mode-autoloads firefox-javascript-repl-autoloads
> flycheck-eglot-autoloads eglot-autoloads git-auto-commit-mode-autoloads
> git-timemachine-autoloads go-guru-autoloads go-rename-autoloads
> go-mode-autoloads graphviz-dot-mode-autoloads ibuffer-project-autoloads
> ioccur-autoloads jinx-autoloads jq-format-autoloads jq-mode-autoloads
> json-mode-autoloads rx json-rpc-autoloads keyfreq-autoloads
> kotlin-mode-autoloads lem-autoloads fedi-autoloads lingva-autoloads
> logview-autoloads datetime-autoloads extmap-autoloads loop-autoloads
> lsp-mode-autoloads ht-autoloads lua-mode-autoloads magit-autoloads pcase
> git-commit-autoloads magit-section-autoloads markdown-mode-autoloads
> mastodon-autoloads meson-mode-autoloads nim-mode-autoloads
> flycheck-autoloads concurrent-autoloads ninja-mode-autoloads
> noaa-autoloads kv-autoloads notmuch-autoloads ob-restclient-autoloads
> paradox-autoloads pass-autoloads f-autoloads password-store-autoloads
> pdf-tools-autoloads pdfgrep-autoloads persist-autoloads popup-autoloads
> prettier-js-autoloads projectile-autoloads protobuf-mode-autoloads
> pydoc-autoloads rcirc-styles-autoloads restclient-autoloads rg-autoloads
> finder-inf ripgrep-autoloads rust-mode-autoloads shx-autoloads
> slime-autoloads macrostep-autoloads swiper-autoloads ivy-autoloads
> tablist-autoloads terraform-mode-autoloads hcl-mode-autoloads
> ts-autoloads unfill-autoloads uptimes-autoloads uxntal-mode-autoloads
> virtualenvwrapper-autoloads dash-autoloads vterm-toggle-autoloads
> vterm-autoloads vundo-autoloads web-mode-autoloads webpaste-autoloads
> request-autoloads websocket-autoloads wgrep-autoloads
> with-editor-autoloads info compat-autoloads xbm-life-autoloads
> yaml-mode-autoloads yasnippet-autoloads zig-mode-autoloads
> reformatter-autoloads package browse-url url url-proxy url-privacy
> url-expand url-methods url-history url-cookie generate-lisp-file
> url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
> eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv
> bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip
> cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
> elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
> fontset image regexp-opt fringe tabulated-list replace newcomment
> text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
> isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
> font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
> indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
> tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
> romanian slovak czech european ethiopic indian cyrillic chinese
> composite emoji-zwj charscript charprop case-table epa-hook
> jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
> theme-loaddefs faces cus-face macroexp files window text-properties
> overlay sha1 md5 base64 format env code-pages mule custom widget keymap
> hashtable-print-readable backquote threads dbusbind inotify
> dynamic-setting font-render-setting x multi-tty make-network-process
> emacs)
>
> Memory information:
> ((conses 16 2899707 503795)
>  (symbols 48 82148 33)
>  (strings 32 476326 91222)
>  (string-bytes 1 155133639)
>  (vectors 16 203538)
>  (vector-slots 8 5762966 693353)
>  (floats 8 38576 4476)
>  (intervals 56 262895 3415)
>  (buffers 984 413))

-- 
Philip Kaludercic