]> git.eshelyaron.com Git - emacs.git/commitdiff
Make nnimap parse pathological spam headers better
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 13 Apr 2018 17:28:17 +0000 (19:28 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 13 Apr 2018 17:28:17 +0000 (19:28 +0200)
* lisp/gnus/nnimap.el (nnimap-transform-headers): Unfold certain
pathological IMAP headers more correctly (bug#25502).  Perhaps
this function should be re-implemented.

lisp/gnus/nnimap.el

index 0d85a29ff2ff971d7ee924680aadfa39f0f37ce8..dc51b5f0f0c2ebf58e9f828080503405ec6d6da6 100644 (file)
@@ -220,15 +220,16 @@ textual parts.")
            (cl-return)))
        (goto-char (match-end 0))
        ;; Unfold quoted {number} strings.
-       (while (re-search-forward
-               "[^]][ (]{\\([0-9]+\\)}\r?\n"
-               (save-excursion
-                 ;; Start of the header section.
-                 (or (re-search-forward "] {[0-9]+}\r?\n" nil t)
-                     ;; Start of the next FETCH.
-                     (re-search-forward "\\* [0-9]+ FETCH" nil t)
-                     (point-max)))
-               t)
+       (while (or (looking-at "[ (]{\\([0-9]+\\)}\r?\n")
+                  (re-search-forward
+                   "[^]][ (]{\\([0-9]+\\)}\r?\n"
+                   (save-excursion
+                     ;; Start of the header section.
+                     (or (re-search-forward "] {[0-9]+}\r?\n" nil t)
+                         ;; Start of the next FETCH.
+                         (re-search-forward "\\* [0-9]+ FETCH" nil t)
+                         (point-max)))
+                   t))
          (setq size (string-to-number (match-string 1)))
          (delete-region (+ (match-beginning 0) 2) (point))
          (setq string (buffer-substring (point) (+ (point) size)))