Subject: bug#34387: 26.1; Gnus: handle empty message parts

From: Katsumi Yamaoka <[email-masked]>
Date: Wed, 13 Feb 2019 13:53:34 +0900

On Tue, 12 Feb 2019 08:31:39 +0100, Christophe Troestler wrote:
> Here is the debugger trace (message attached) :

> Debugger entered--Lisp error: (args-out-of-range 4409 4410)
>   #f(compiled-function...)(PART1)
>   apply(#f(compiled-function...) PART1)
>   gnus-mime-display-single@fix(#f(compiled-function...) PART1)
>   apply(gnus-mime-display-single@fix #f(compiled-function...) PART1)
>   gnus-mime-display-single(PART1)
>   gnus-mime-display-part(PART1)
>   mapcar(gnus-mime-display-part (PART1 PART2))
>   gnus-mime-display-mixed((PART1 PART2))
>   gnus-mime-display-part((...PART1 PART2))
>   gnus-display-mime()
>   gnus-article-prepare-display()

;; Where PART1 is the html part and PART2 is the pdf part.

If it is (narrow-to-region beg (point)) in gnus-mime-display-single
to issue (args-out-of-range 4409 4410), I guess an html rendering
function deletes buffer's contents so that the buffer's end point
may be 4409.  Here is a model to reproduce the same error:

(with-temp-buffer               ;; article buffer
  (insert-char ?x 4409)
  (let ((beg (point)))          ;; buffer's end point == 4410
    (delete-char -1)            ;; html function does this
    (narrow-to-region beg (point))))
 => (args-out-of-range 4409 4410)

The default html function is mm-shr, that gnus-mime-display-single
calls by way of mm-display-part, mm-display-inline, and
mm-inline-text-html.  At that time, the point is positioned at
the end of the article buffer, where the header lines and a
single empty line are there.

>> Otherwise, could you show me a sample email in question? […]
> Attached.

Thanks.  However, I couldn't reproduce the error with the mail
that I copied to my nnml group.  I tried it using Emacs 26.1
with no ~/.emacs, no ~/.gnus.el, but ~/.newsrc.eld,
(setq gnus-select-method '(nnnil)), and every candidate for
mm-text-html-renderer.  The only thing that reproduces it is:

(defadvice mm-shr (before delete-ceiling-newlines activate)
  "Delete newlines before the point."
  (skip-chars-backward "\n")
  (delete-region (point) (point-max)))

Well, if you have time for analyzing the problem, don't you try
edebug on the functions listed above?

Regards,

;; I'm going to fix the other 2 issues anyway.