]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infloop when folding difficult headers in Message
authorLars Ingebrigtsen <larsi@gnus.org>
Sun, 20 Sep 2020 22:26:54 +0000 (00:26 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 20 Sep 2020 22:26:54 +0000 (00:26 +0200)
* lisp/mail/rfc2047.el (rfc2047-fold-field): Return the end point.
* lisp/gnus/message.el (message--fold-long-headers): Use that to
reliably achieve progress.

lisp/gnus/message.el
lisp/mail/rfc2047.el

index 3e7e18906c6be28bd355931720916d1c33a95de5..16f47c8d4c1881f439860dc07b9336c394b4b1b1 100644 (file)
@@ -4843,10 +4843,10 @@ If you always want Gnus to send messages in one piece, set
 Each line should be no more than 79 characters long."
   (goto-char (point-min))
   (while (not (eobp))
-    (when (and (looking-at "[^:]+:")
-               (> (- (line-end-position) (point)) 79))
-      (mail-header-fold-field))
-    (forward-line 1)))
+    (if (and (looking-at "[^:]+:")
+             (> (- (line-end-position) (point)) 79))
+       (goto-char (mail-header-fold-field))
+      (forward-line 1))))
 
 (defvar sendmail-program)
 (defvar smtpmail-smtp-server)
index 234f319669fef5e12ac3866af44a03ffb3af5aaa..4aa0c2809b20e1ddb9d22c89e0d98bfb845b7a01 100644 (file)
@@ -716,11 +716,13 @@ Point moves to the end of the region."
           (goto-char e)))))
 
 (defun rfc2047-fold-field ()
-  "Fold the current header field."
+  "Fold the current header field.
+Return the new end point."
   (save-excursion
     (save-restriction
       (rfc2047-narrow-to-field)
-      (rfc2047-fold-region (point-min) (point-max)))))
+      (rfc2047-fold-region (point-min) (point-max))
+      (point-max))))
 
 (defun rfc2047-fold-region (b e)
   "Fold long lines in region B to E."