GNU bug report logs - #58227
29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sat, 1 Oct 2022 14:36:02 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.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 58227 in the body.
You can then email your comments to 58227 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#58227; Package emacs. (Sat, 01 Oct 2022 14:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 01 Oct 2022 14:36:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in
 url/cookies
Date: Sat, 01 Oct 2022 10:35:33 -0400
Package: Emacs
Version: 29.0.50


`gnus-read-ephemeral-bug-group` can cause the ~/emacs.d/url/cookies
file (which is labeled with a `coding: utf-8-emacs-unix` cookie) to be
read as a binary file.  This may look somewhat minor but it's a symptom
of a further reaching problem.

The code does the following:

          (let ((coding-system-for-write 'binary)
                (coding-system-for-read 'binary))
            (with-temp-file tmpfile
              (mm-disable-multibyte)
              (dolist (id ids)
                (let ((file (expand-file-name id (locate-user-emacs-file
                                                  "debbugs-cache"))))
                  (if (and (not gnus-plugged)
                           (file-exists-p file))
                      (insert-file-contents file)
                    ;; Pass non-nil VISIT to avoid errors with non-nil
                    ;; `url-automatic-caching' (bug#26063, bug#29008)
                    ;; and immediately unvisit.
                    ;; FIXME: This masks real errors!
                    (url-insert-file-contents (format mbox-url id) t)
                    (setq buffer-file-name nil))))
	      (goto-char (point-min))
              ;; Throw an informative error early instead of passing nonsense
              ;; to `gnus-group-read-ephemeral-group' (bug#36433).
              (unless (save-excursion (re-search-forward delim nil t))
                (error "Invalid mbox format for bug IDs: %s"
                       (string-join ids ", ")))
              (while (re-search-forward delim nil t)
                (narrow-to-region (point)
                                  (if (search-forward "\n\n" nil t)
                                      (1- (point))
                                    (point-max)))
                (unless (string-match-p address-re
                                        (concat (message-fetch-field "to") " "
                                                (message-fetch-field "cc")))
                  (goto-char (point-min))
                  (if (not (re-search-forward "^To:" nil t))
                      (insert "To: " address "\n")
		    (message-next-header)
		    (skip-chars-backward "\t\n ")
                    (insert ", " address)))
                (goto-char (point-max))
                (widen))))

Any ELisp source file loaded while executing this code (such as
autoloaded files, or ~/.emacs.d/url/cookies which gets read via
url-insert-file-contents => url-retrieve-synchronously => url-do-setup
=> url-cookie-parse-file) will be decoded as a binary file rather than
as UTF-8.

And any other auxiliary reading/writing of files and processes that
could be happening along the way would also be affected by the
`coding-system-for-read/write` bindings.

This is a general problem with let-binding
`coding-system-for-read/write`, which is sometimes the only way to get
what we need from ELisp.  In this case, maybe we can use
`insert-file-contents-literally` (and maybe we should introduce
a `url-insert-file-contents-literally` too?).


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58227; Package emacs. (Sun, 02 Oct 2022 12:59:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 58227 <at> debbugs.gnu.org
Subject: Re: bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides
 `coding` cookie in url/cookies
Date: Sun, 02 Oct 2022 14:58:39 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> This is a general problem with let-binding
> `coding-system-for-read/write`, which is sometimes the only way to get
> what we need from ELisp.  In this case, maybe we can use
> `insert-file-contents-literally` (and maybe we should introduce
> a `url-insert-file-contents-literally` too?).

Now done in Emacs 29.




bug marked as fixed in version 29.1, send any further explanations to 58227 <at> debbugs.gnu.org and Stefan Monnier <monnier <at> iro.umontreal.ca> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 02 Oct 2022 12:59:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#58227; Package emacs. (Mon, 03 Oct 2022 00:34:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 58227-done <at> debbugs.gnu.org
Subject: Re: bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides
 `coding` cookie in url/cookies
Date: Sun, 02 Oct 2022 20:33:20 -0400
Lars Ingebrigtsen [2022-10-02 14:58:39] wrote:
> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> This is a general problem with let-binding
>> `coding-system-for-read/write`, which is sometimes the only way to get
>> what we need from ELisp.  In this case, maybe we can use
>> `insert-file-contents-literally` (and maybe we should introduce
>> a `url-insert-file-contents-literally` too?).
> Now done in Emacs 29.

Thanks,


        Stefan





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

This bug report was last modified 2 years and 256 days ago.

Previous Next


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