Commit 97934ffb authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

Attach text files correctly in Message

* lisp/gnus/mml.el (mml-generate-mime-1): Detect which coding
system has been used in attached text files, and don't try to
do any encoding of these files (bug#13808).
parent 6bfa9e9a
......@@ -486,7 +486,8 @@ be \"related\" or \"alternate\"."
(equal (cdr (assq 'type (car cont))) "text/html"))
(setq cont (mml-expand-html-into-multipart-related (car cont))))
(set-buffer-multibyte nil)
(setq message-options options)
((and (consp (car cont))
......@@ -605,15 +606,18 @@ be \"related\" or \"alternate\"."
(intern (downcase charset))))))
(if (and (not raw)
(member (car (split-string type "/")) '("text" "message")))
;; We have a text-like MIME part, so we need to do
;; charset encoding.
(set-buffer-multibyte nil)
;; First insert the data into the buffer.
((cdr (assq 'buffer cont))
(insert-buffer-substring (cdr (assq 'buffer cont))))
((and filename
(not (equal (cdr (assq 'nofile cont)) "yes")))
(let ((coding-system-for-read coding))
(mm-insert-file-contents filename)))
(mm-insert-file-contents filename))
((eq 'mml (car cont))
(insert (cdr (assq 'contents cont))))
......@@ -667,21 +671,22 @@ be \"related\" or \"alternate\"."
;; insert a "; format=flowed" string unless the
;; user has already specified it.
(setq flowed (null (assq 'format cont)))))
;; Prefer `utf-8' for text/calendar parts.
(if (or charset
(not (string= type "text/calendar")))
(setq charset (mm-encode-body charset))
(let ((mm-coding-system-priorities
(cons 'utf-8 mm-coding-system-priorities)))
(setq charset (mm-encode-body))))
(unless charset
(setq charset
;; Prefer `utf-8' for text/calendar parts.
(if (string= type "text/calendar")
(point-min) (point-max) t)))))
(setq encoding (mm-body-encoding
charset (cdr (assq 'encoding cont))))))
(setq coded (buffer-string)))
(mml-insert-mime-headers cont type charset encoding flowed)
(insert "\n")
(insert coded))
(set-buffer-multibyte nil)
((cdr (assq 'buffer cont))
(insert (string-as-unibyte
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment