* bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies
@ 2022-10-01 14:35 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-02 12:58 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-01 14:35 UTC (permalink / raw)
To: 58227
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies
2022-10-01 14:35 bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-10-02 12:58 ` Lars Ingebrigtsen
2022-10-03 0:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-02 12:58 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 58227
Stefan Monnier <monnier@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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies
2022-10-02 12:58 ` Lars Ingebrigtsen
@ 2022-10-03 0:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-03 0:33 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 58227-done
Lars Ingebrigtsen [2022-10-02 14:58:39] wrote:
> Stefan Monnier <monnier@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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-03 0:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 14:35 bug#58227: 29.0.50; gnus-read-ephemeral-bug-group overrides `coding` cookie in url/cookies Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-02 12:58 ` Lars Ingebrigtsen
2022-10-03 0:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).