guile: avoid body duplication
In message, don't re-fill when unneeded. Add tests. Fixes #2802.
This commit is contained in:
@ -333,7 +333,7 @@ SCM_DEFINE(get_parts,
|
|||||||
attlist = scm_cons(elm, attlist);
|
attlist = scm_cons(elm, attlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* explicitly close the file backend, so we won't run of fds */
|
/* explicitly close the file backend, so we won't run out of fds */
|
||||||
msg->unload_mime_message();
|
msg->unload_mime_message();
|
||||||
|
|
||||||
return attlist;
|
return attlist;
|
||||||
|
|||||||
@ -74,7 +74,10 @@ exec guile -e main -s $0 $@
|
|||||||
(str-equal-or-exit (mu:subject msg) "Fwd: rfc822")
|
(str-equal-or-exit (mu:subject msg) "Fwd: rfc822")
|
||||||
(str-equal-or-exit (mu:to msg) "martin")
|
(str-equal-or-exit (mu:to msg) "martin")
|
||||||
(str-equal-or-exit (mu:from msg) "foobar <foo@example.com>")
|
(str-equal-or-exit (mu:from msg) "foobar <foo@example.com>")
|
||||||
|
(str-equal-or-exit (mu:body msg) "Hello world, forwarding some RFC822 message\n")
|
||||||
(str-equal-or-exit (mu:header msg "X-Mailer") "Ximian Evolution 1.4.5")
|
(str-equal-or-exit (mu:header msg "X-Mailer") "Ximian Evolution 1.4.5")
|
||||||
|
;; issue #2802
|
||||||
|
(str-equal-or-exit (mu:body msg) "Hello world, forwarding some RFC822 message\n")
|
||||||
|
|
||||||
(if (not (equal? (mu:priority msg) mu:prio:normal))
|
(if (not (equal? (mu:priority msg) mu:prio:normal))
|
||||||
(error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal)))
|
(error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal)))
|
||||||
|
|||||||
@ -72,6 +72,10 @@ struct Message::Private {
|
|||||||
|
|
||||||
Option<std::string> language; /* body ISO language code */
|
Option<std::string> language; /* body ISO language code */
|
||||||
|
|
||||||
|
// after unload_mime_message, we don't need to re-parse the message.
|
||||||
|
// issue #2802.
|
||||||
|
bool document_filled{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Document::Options doc_opts(Message::Options mopts) {
|
Document::Options doc_opts(Message::Options mopts) {
|
||||||
return any_of(opts & Message::Options::SupportNgrams) ?
|
return any_of(opts & Message::Options::SupportNgrams) ?
|
||||||
@ -675,6 +679,10 @@ doc_add_reply_to(Document& doc, const MimeMessage& mime_msg)
|
|||||||
static void
|
static void
|
||||||
fill_document(Message::Private& priv)
|
fill_document(Message::Private& priv)
|
||||||
{
|
{
|
||||||
|
if (priv.document_filled) {
|
||||||
|
return; // nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
/* hunt & gather info from message tree */
|
/* hunt & gather info from message tree */
|
||||||
Document& doc{priv.doc};
|
Document& doc{priv.doc};
|
||||||
MimeMessage& mime_msg{priv.mime_msg.value()};
|
MimeMessage& mime_msg{priv.mime_msg.value()};
|
||||||
@ -691,7 +699,7 @@ fill_document(Message::Private& priv)
|
|||||||
doc_add_list_post(doc, mime_msg); /* only in sexp */
|
doc_add_list_post(doc, mime_msg); /* only in sexp */
|
||||||
doc_add_reply_to(doc, mime_msg); /* only in sexp */
|
doc_add_reply_to(doc, mime_msg); /* only in sexp */
|
||||||
|
|
||||||
field_for_each([&](auto&& field) {
|
field_for_each([&](const auto& field) {
|
||||||
/* insist on explicitly handling each */
|
/* insist on explicitly handling each */
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic error "-Wswitch"
|
#pragma GCC diagnostic error "-Wswitch"
|
||||||
@ -775,6 +783,8 @@ fill_document(Message::Private& priv)
|
|||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
priv.document_filled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Option<std::string>
|
Option<std::string>
|
||||||
|
|||||||
Reference in New Issue
Block a user