summaryrefslogtreecommitdiff
path: root/lisp/url
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-10-02 14:58:25 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-10-02 15:50:02 +0200
commit4efb2ef57237147111de90781755f666b3cb9bdd (patch)
treea3ea86308e81165b07ceaac53edf1033deceec57 /lisp/url
parente922940674eb7cd7d604182732c310c6823f23ae (diff)
downloademacs-4efb2ef57237147111de90781755f666b3cb9bdd.tar.gz
Fix coding system problems in gnus-read-ephemeral-bug-group
* lisp/gnus/gnus-group.el (gnus-read-ephemeral-bug-group): Don't bind coding system variables, because that leads to loading other files (like cookie files) using that coding system (bug#58227). * lisp/url/url-handlers.el (url-insert-file-literally): New function. (url-insert): Allow forcing no-decode.
Diffstat (limited to 'lisp/url')
-rw-r--r--lisp/url/url-handlers.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index 74f77cd2383..b66c187c547 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -302,11 +302,13 @@ accessible."
filename))
(put 'file-local-copy 'url-file-handlers #'url-file-local-copy)
-(defun url-insert (buffer &optional beg end)
+(defun url-insert (buffer &optional beg end inhibit-decode)
"Insert the body of a URL object.
BUFFER should be a complete URL buffer as returned by `url-retrieve'.
If the headers specify a coding-system (and current buffer is multibyte),
-it is applied to the body before it is inserted.
+it is applied to the body before it is inserted. If INHIBIT-DECODE is
+non-nil, don't do any coding system decoding even in multibyte buffers.
+
Returns a list of the form (SIZE CHARSET), where SIZE is the size in bytes
of the inserted text and CHARSET is the charset that was specified in the
header, or nil if none was found.
@@ -318,7 +320,8 @@ They count bytes from the beginning of the body."
(buffer-substring (+ (point-min) beg)
(if end (+ (point-min) end) (point-max)))
(buffer-string))))
- (charset (if enable-multibyte-characters
+ (charset (if (and enable-multibyte-characters
+ (not inhibit-decode))
(mail-content-type-get (mm-handle-type handle)
'charset))))
(mm-destroy-parts handle)
@@ -362,6 +365,14 @@ if it had been inserted from a file named URL."
(url-insert-buffer-contents buffer url visit beg end replace)))
(put 'insert-file-contents 'url-file-handlers #'url-insert-file-contents)
+;;;###autoload
+(defun url-insert-file-contents-literally (url)
+ "Insert the data retrieved from URL literally in the current buffer."
+ (let ((buffer (url-retrieve-synchronously url)))
+ (unless buffer
+ (signal 'file-error (list url "No Data")))
+ (url-insert buffer nil nil t)))
+
(defun url-file-name-completion (url _directory &optional _predicate)
;; Even if it's not implemented, it's not an error to ask for completion,
;; in case it's available (bug#14806).