GNU bug report logs - #63343
30.0.50; generated mode function will error if mode name contains '%'

Previous Next

Package: emacs;

Reported by: No Wayman <iarchivedmywholelife <at> gmail.com>

Date: Sun, 7 May 2023 04:10:01 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63343 in the body.
You can then email your comments to 63343 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#63343; Package emacs. (Sun, 07 May 2023 04:10:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to No Wayman <iarchivedmywholelife <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 07 May 2023 04:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: No Wayman <iarchivedmywholelife <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; generated mode function will error if mode name contains '%'
Date: Sat, 06 May 2023 23:46:10 -0400
[Message part 1 (text/plain, inline)]

Mode functions generated via `define-minor-mode' will signal an 
error when messaging a mode's "pretty" name contains "%".

To reproduce:

1. eval: (define-minor-mode 100%-failure-mode "oops")
2. enable or disable the mode.

The line responsible for the error is:

(message ,(format "%s %%sabled%%s" pretty-name) 
        (if ,getter "en" "dis") local)))))

The attached patch fixes the issue for me.

[0001-define-minor-mode-sanitize-mode-function-messages.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.37, cairo version 1.17.8) of 2023-04-14 built on nbook
Repository revision: dc842a71ed035dab1115f2e67d35dd07410e18be
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 
11.0.12101008
System Description: Arch Linux


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63343; Package emacs. (Sun, 07 May 2023 05:39:02 GMT) Full text and rfc822 format available.

Message #8 received at 63343 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: No Wayman <iarchivedmywholelife <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 63343 <at> debbugs.gnu.org
Subject: Re: bug#63343: 30.0.50;
 generated mode function will error if mode name contains '%'
Date: Sun, 07 May 2023 08:38:57 +0300
> From: No Wayman <iarchivedmywholelife <at> gmail.com>
> Date: Sat, 06 May 2023 23:46:10 -0400
> 
> Mode functions generated via `define-minor-mode' will signal an 
> error when messaging a mode's "pretty" name contains "%".
> 
> To reproduce:
> 
> 1. eval: (define-minor-mode 100%-failure-mode "oops")
> 2. enable or disable the mode.
> 
> The line responsible for the error is:
> 
> (message ,(format "%s %%sabled%%s" pretty-name) 
>          (if ,getter "en" "dis") local)))))
> 
> The attached patch fixes the issue for me.
> 
> >From eb3b41cb4237352aca68e5b14e528cb854c4ab5a Mon Sep 17 00:00:00 2001
> From: Nicholas Vollmer <iarchivedmywholelife <at> gmail.com>
> Date: Sun, 7 May 2023 00:06:18 -0400
> Subject: [PATCH] define-minor-mode: sanitize mode function messages
> 
> * emacs-lisp/easy-mmode.el (define-minor-mode): Ensure mode's pretty
>   name is not interprted as a message formatting string.  e.g. if the
>   mode name contains a '%'.
> ---
>  lisp/emacs-lisp/easy-mmode.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
> index 84e131147cd..3c6a215c9dc 100644
> --- a/lisp/emacs-lisp/easy-mmode.el
> +++ b/lisp/emacs-lisp/easy-mmode.el
> @@ -391,7 +391,7 @@ define-minor-mode
>                                   (not (equal ,last-message
>                                               (current-message))))
>                        (let ((local ,(if globalp "" " in current buffer")))
> -			(message ,(format "%s %%sabled%%s" pretty-name)
> +			(message "%s %sabled%s" ,pretty-name
>  			         (if ,getter "en" "dis") local)))))
>  	      ,@(when after-hook `(,after-hook)))
>  	    (force-mode-line-update)
> -- 

Thanks.

Stefan, any objections to installing this on the release branch?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63343; Package emacs. (Sun, 07 May 2023 13:32:02 GMT) Full text and rfc822 format available.

Message #11 received at 63343 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63343 <at> debbugs.gnu.org, No Wayman <iarchivedmywholelife <at> gmail.com>
Subject: Re: bug#63343: 30.0.50; generated mode function will error if mode
 name contains '%'
Date: Sun, 07 May 2023 09:30:57 -0400
>> -			(message ,(format "%s %%sabled%%s" pretty-name)
>> +			(message "%s %sabled%s" ,pretty-name

Ugh!

> Stefan, any objections to installing this on the release branch?

Not at all.


        Stefan





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sun, 07 May 2023 13:39:01 GMT) Full text and rfc822 format available.

Notification sent to No Wayman <iarchivedmywholelife <at> gmail.com>:
bug acknowledged by developer. (Sun, 07 May 2023 13:39:02 GMT) Full text and rfc822 format available.

Message #16 received at 63343-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 63343-done <at> debbugs.gnu.org, iarchivedmywholelife <at> gmail.com
Subject: Re: bug#63343: 30.0.50; generated mode function will error if mode
 name contains '%'
Date: Sun, 07 May 2023 16:39:06 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: No Wayman <iarchivedmywholelife <at> gmail.com>,  63343 <at> debbugs.gnu.org
> Date: Sun, 07 May 2023 09:30:57 -0400
> 
> >> -			(message ,(format "%s %%sabled%%s" pretty-name)
> >> +			(message "%s %sabled%s" ,pretty-name
> 
> Ugh!
> 
> > Stefan, any objections to installing this on the release branch?
> 
> Not at all.

Thanks, installed on emacs-29, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 05 Jun 2023 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 297 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.