Work for empty MIME attachments (related to bug#34387)

* mm-view.el (mm-inline-text):
Make undisplayer do nothing if the part is empty.

* mm-decode.el (mm-copy-to-buffer): Work for empty MIME part.
* mml.el (mime-to-mml): Ditto.
This commit is contained in:
Katsumi Yamaoka 2019-02-14 02:16:05 +00:00
parent 58e0e929af
commit 25d9fe24a6
3 changed files with 11 additions and 7 deletions

View file

@ -764,7 +764,7 @@ MIME-Version header before proceeding."
(mb (mm-multibyte-p)) (mb (mm-multibyte-p))
beg) beg)
(goto-char (point-min)) (goto-char (point-min))
(search-forward-regexp "^\n" nil t) (search-forward-regexp "^\n" nil 'move) ;; There might be no body.
(setq beg (point)) (setq beg (point))
(with-current-buffer (with-current-buffer
(generate-new-buffer " *mm*") (generate-new-buffer " *mm*")

View file

@ -368,10 +368,12 @@
(enriched-decode (point-min) (point-max)))) (enriched-decode (point-min) (point-max))))
(mm-handle-set-undisplayer (mm-handle-set-undisplayer
handle handle
(if (= (point-min) (point-max))
#'ignore
`(lambda () `(lambda ()
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(delete-region ,(copy-marker (point-min) t) (delete-region ,(copy-marker (point-min) t)
,(point-max-marker)))))))) ,(point-max-marker)))))))))
(defun mm-insert-inline (handle text) (defun mm-insert-inline (handle text)
"Insert TEXT inline from HANDLE." "Insert TEXT inline from HANDLE."

View file

@ -979,8 +979,10 @@ If HANDLES is non-nil, use it instead reparsing the buffer."
(unless handles (unless handles
(setq handles (mm-dissect-buffer t))) (setq handles (mm-dissect-buffer t)))
(goto-char (point-min)) (goto-char (point-min))
(search-forward "\n\n" nil t) (if (search-forward "\n\n" nil 'move)
(delete-region (point) (point-max)) (delete-region (point) (point-max))
;; No content in the part that is the sole part of this message.
(insert (if (bolp) "\n" "\n\n")))
(if (stringp (car handles)) (if (stringp (car handles))
(mml-insert-mime handles) (mml-insert-mime handles)
(mml-insert-mime handles t)) (mml-insert-mime handles t))