aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2017-01-26 21:12:05 +0100
committerLars Ingebrigtsen2017-01-26 21:12:05 +0100
commit301ee3d0319d489087bc548beb2ea5e7900224b6 (patch)
tree737b60ef9af4ea3ea7851f86f8d207c76c49f9f3
parentb720f1a33636b3764ef82bdb6d69e2d627304fea (diff)
downloademacs-301ee3d0319d489087bc548beb2ea5e7900224b6.tar.gz
emacs-301ee3d0319d489087bc548beb2ea5e7900224b6.zip
Avoid a regexp overflow in message-goto-body
* lisp/gnus/message.el (message-goto-body-1): Avoid using a complicated backtracking regexp, because they may overflow on large headers (bug#21160).
-rw-r--r--lisp/gnus/message.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index ce0d9769a5a..9af38c01ed7 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -3111,16 +3111,26 @@ M-RET `message-newline-and-reformat' (break the line and reformat)."
3111 (message-goto-body-1)) 3111 (message-goto-body-1))
3112 3112
3113(defun message-goto-body-1 () 3113(defun message-goto-body-1 ()
3114 "Go to the body and return point."
3114 (goto-char (point-min)) 3115 (goto-char (point-min))
3115 (or (search-forward (concat "\n" mail-header-separator "\n") nil t) 3116 (or (search-forward (concat "\n" mail-header-separator "\n") nil t)
3116 (search-forward-regexp "[^:]+:\\([^\n]\\|\n[ \t]\\)+\n\n" nil t))) 3117 ;; If the message is mangled, find the end of the headers the
3118 ;; hard way.
3119 (progn
3120 ;; Skip past all headers and continuation lines.
3121 (while (looking-at "[^:]+:\\|[\t ]+[^\t ]")
3122 (forward-line 1))
3123 ;; We're now at the first empty line, so perhaps move past it.
3124 (when (and (eolp)
3125 (not (eobp)))
3126 (forward-line 1))
3127 (point))))
3117 3128
3118(defun message-in-body-p () 3129(defun message-in-body-p ()
3119 "Return t if point is in the message body." 3130 "Return t if point is in the message body."
3120 (>= (point) 3131 (>= (point)
3121 (save-excursion 3132 (save-excursion
3122 (message-goto-body-1) 3133 (message-goto-body-1))))
3123 (point))))
3124 3134
3125(defun message-goto-eoh () 3135(defun message-goto-eoh ()
3126 "Move point to the end of the headers." 3136 "Move point to the end of the headers."