Subject: bug#29047: 26.0.90; shr hang (regression from 25.3)

From: Eli Zaretskii <[email-masked]>
Date: Sun, 29 Oct 2017 16:07:34 +0200

> From: Mike Kupfer <[email-masked]>
> Date: Sat, 28 Oct 2017 16:58:20 -0700
> 
> Displaying the attached email with MH-E (using "emacs -Q") or Gnus leads
> to a hang in shr (CPU is pegged, I waited for 5 minutes before giving
> up).  The HTML looks pretty gnarly, but Emacs 25.3 displays the message
> just fine, with maybe a pause of a couple seconds.

(Sending such a message as an inline HTML attachment to people most of
whom can be assumed to use Emacs to read email, which will use shr, is
not very friendly, okay?)

Thanks, this bug was introduced by 9eb028f, and the problematic
property is 'display' with value '(space :align-to (NNN))'.  It
causes shr-fill-line to infloop when this property is put on a
newline.

I can prevent the loop with the patch below.  I'm not sure this is the
right fix, though.  Comments?

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index c90d71d..067a3b9 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -704,8 +704,11 @@ shr-fill-line
 	    (gap-start (point)))
 	(insert "\n")
 	(shr-indent)
-	(when props
-	  (add-text-properties gap-start (point) props)))
+	(while props
+	  (let ((type (pop props))
+		(value (pop props)))
+	    (unless (eq type 'display)
+	      (put-text-property gap-start (point) type value)))))
       (setq start (point))
       (shr-vertical-motion shr-internal-width)
       (when (looking-at " $")