Use message-field-value instead of message-fetch-field in FCC header setup.

For message-fetch-field the buffer is expected to be narrowed to
just the header of the message.  That is not the case when
notmuch-fcc-header-setup is run, hence a wrong header value may be
returned.  E.g. when forwarding an
email, (message-fetch-field "From") returns the From header value
of the forwarded email.

Message-field-value is the same as message-fetch-field, only
narrows the buffer to the headers first.

Signed-off-by: Jameson Graef Rollins <jrollins@finestructure.net>
This commit is contained in:
Dmitry Kurochkin 2011-05-28 14:51:50 -07:00 committed by Carl Worth
parent 6ae4e7d88b
commit a0f09b4942

View file

@ -80,7 +80,7 @@ will NOT be removed or replaced."
(let ((subdir (let ((subdir
(cond (cond
((or (not notmuch-fcc-dirs) ((or (not notmuch-fcc-dirs)
(message-fetch-field "Fcc")) (message-field-value "Fcc"))
;; Nothing set or an existing header. ;; Nothing set or an existing header.
nil) nil)
@ -93,7 +93,7 @@ will NOT be removed or replaced."
(error "Invalid `notmuch-fcc-dirs' setting (old style)")) (error "Invalid `notmuch-fcc-dirs' setting (old style)"))
((listp notmuch-fcc-dirs) ((listp notmuch-fcc-dirs)
(let* ((from (message-fetch-field "From")) (let* ((from (message-field-value "From"))
(match (match
(catch 'first-match (catch 'first-match
(dolist (re-folder notmuch-fcc-dirs) (dolist (re-folder notmuch-fcc-dirs)
@ -118,7 +118,7 @@ will NOT be removed or replaced."
(concat (notmuch-database-path) "/" subdir))))) (concat (notmuch-database-path) "/" subdir)))))
;; finally test if fcc points to a valid maildir ;; finally test if fcc points to a valid maildir
(let ((fcc-header (message-fetch-field "Fcc"))) (let ((fcc-header (message-field-value "Fcc")))
(unless (notmuch-maildir-fcc-dir-is-maildir-p fcc-header) (unless (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
(cond ((not (file-writable-p fcc-header)) (cond ((not (file-writable-p fcc-header))
(error (format "No permission to create %s, which does not exist" (error (format "No permission to create %s, which does not exist"