summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-03-20 04:55:20 +0000
committerRichard M. Stallman <rms@gnu.org>1997-03-20 04:55:20 +0000
commit9c6f6eff1895e7336753bc9c4ca7f9f2ec9f9add (patch)
treee3e37aa2978aba51bf3e779a67ed19570944b14c
parent04349e07ab9a45fae393f565384331b7b6a927c8 (diff)
downloademacs-9c6f6eff1895e7336753bc9c4ca7f9f2ec9f9add.tar.gz
(rmail-retry-failure): Special handling for mime.
(mail-mime-unsent-header): New variable.
-rw-r--r--lisp/mail/rmail.el44
1 files changed, 30 insertions, 14 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 8eb37907f4c..8fc8f012457 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2621,11 +2621,16 @@ typically for purposes of moderating a list."
"^|? *---+ +Message text follows: +---+ *|?$")
"A regexp that matches the separator before the text of a failed message.")
+(defvar mail-mime-unsent-header "^Content-Type: message/rfc822 *$"
+ "A regexp that matches the header of a MIME body part with a failed message.")
+
(defun rmail-retry-failure ()
"Edit a mail message which is based on the contents of the current message.
For a message rejected by the mail system, extract the interesting headers and
the body of the original message.
-The variable `mail-unsent-separator' should match the string that
+If the failed message is a MIME multipart message, it is searched for a
+body part with a header which matches the variable `mail-mime-unsent-header'.
+Otherwise, the variable `mail-unsent-separator' should match the string that
delimits the returned original message.
The variable `rmail-retry-ignored-headers' is a regular expression
specifying headers which should not be copied into the new message."
@@ -2637,23 +2642,34 @@ specifying headers which should not be copied into the new message."
(save-excursion
;; Narrow down to just the quoted original message
(rmail-beginning-of-message)
- (let ((case-fold-search t))
- (if (search-forward "This is a MIME-encapsulated message\n\n--" nil t)
+ (let* ((case-fold-search t)
+ (top (point))
+ (content-type
+ (save-restriction
+ ;; Fetch any content-type header in current message
+ (search-forward "\n\n") (narrow-to-region top (point))
+ (mail-fetch-field "Content-Type") )) )
+ ;; Handle MIME multipart bounce messages
+ (if (and content-type
+ (string-match
+ ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=?]+\\)\"?"
+ content-type))
(let ((codestring
- (buffer-substring (progn (beginning-of-line) (point))
- (progn (end-of-line) (point)))))
- (or (re-search-forward mail-unsent-separator nil t)
+ (concat "\n--"
+ (substring content-type (match-beginning 1)
+ (match-end 1)))))
+ (or (re-search-forward mail-mime-unsent-header nil t)
(error "Cannot find beginning of header in failed message"))
- (or (and (search-forward codestring nil t)
- (search-forward "\n\n" nil t))
+ (or (search-forward "\n\n" nil t)
(error "Cannot find end of Mime data in failed message"))
(setq bounce-start (point))
- (save-excursion
- (goto-char (point-max))
- (search-backward codestring)
- (setq bounce-end (point)))
- (or (search-forward "\n\n" nil t)
- (error "Cannot find end of header in failed message")))
+ (or (search-forward codestring nil t)
+ (error "Cannot find end of Mime data in failed message"))
+ (setq bounce-end (match-beginning 0))
+; (or (search-forward "\n\n" nil t)
+; (error "Cannot find end of header in failed message"))
+ )
+ ;; non-MIME bounce
(or (re-search-forward mail-unsent-separator nil t)
(error "Cannot parse this as a failure message"))
(skip-chars-forward "\n")