diff --git a/guile/mu-guile-message.cc b/guile/mu-guile-message.cc index 281ed7c4..24223c30 100644 --- a/guile/mu-guile-message.cc +++ b/guile/mu-guile-message.cc @@ -333,7 +333,7 @@ SCM_DEFINE(get_parts, 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(); return attlist; diff --git a/guile/tests/test-mu-guile.scm b/guile/tests/test-mu-guile.scm index ed00f1e3..7926d112 100755 --- a/guile/tests/test-mu-guile.scm +++ b/guile/tests/test-mu-guile.scm @@ -74,10 +74,13 @@ exec guile -e main -s $0 $@ (str-equal-or-exit (mu:subject msg) "Fwd: rfc822") (str-equal-or-exit (mu:to msg) "martin") (str-equal-or-exit (mu:from msg) "foobar ") + (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") + ;; 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)) - (error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal))) + (error-exit "Expected ~A, got ~A" (mu:priority msg) mu:prio:normal))) (let ((msg (car (mu:message-list "atoms")))) (str-equal-or-exit (mu:subject msg) "atoms") @@ -85,21 +88,21 @@ exec guile -e main -s $0 $@ (str-equal-or-exit (mu:from msg) "Richard P. Feynman ") ;;(str-equal-or-exit (mu:header msg "Content-Transfer-Encoding") "8bit") (str-equal-or-exit (mu:body msg) - (string-join - '("If, in some cataclysm, all scientific knowledge were to be destroyed," - "and only one sentence passed on to the next generation of creatures," - "what statement would contain the most information in the fewest words?" - "I believe it is the atomic hypothesis (or atomic fact, or whatever you" - "wish to call it) that all things are made of atoms — little particles" - "that move around in perpetual motion, attracting each other when they" - "are a little distance apart, but repelling upon being squeezed into" - "one another. In that one sentence you will see an enormous amount of" - "information about the world, if just a little imagination and thinking" - "are applied.\n") "\n")) + (string-join + '("If, in some cataclysm, all scientific knowledge were to be destroyed," + "and only one sentence passed on to the next generation of creatures," + "what statement would contain the most information in the fewest words?" + "I believe it is the atomic hypothesis (or atomic fact, or whatever you" + "wish to call it) that all things are made of atoms — little particles" + "that move around in perpetual motion, attracting each other when they" + "are a little distance apart, but repelling upon being squeezed into" + "one another. In that one sentence you will see an enormous amount of" + "information about the world, if just a little imagination and thinking" + "are applied.\n") "\n")) (str-equal-or-exit (mu:body-txt msg) (mu:body msg)) (let ((got (mu:body-html msg))) (if got - (error-exit "Expected #f, got ~a" got))) + (error-exit "Expected #f, got ~a" got))) (if (not (equal? (mu:priority msg) mu:prio:high)) (error-exit "Expected ~a, got ~a" (mu:priority msg) mu:prio:high)))) diff --git a/lib/message/mu-message.cc b/lib/message/mu-message.cc index ee592980..3d4d2df2 100644 --- a/lib/message/mu-message.cc +++ b/lib/message/mu-message.cc @@ -72,6 +72,10 @@ struct Message::Private { Option language; /* body ISO language code */ + // after unload_mime_message, we don't need to re-parse the message. + // issue #2802. + bool document_filled{}; + private: Document::Options doc_opts(Message::Options mopts) { return any_of(opts & Message::Options::SupportNgrams) ? @@ -675,6 +679,10 @@ doc_add_reply_to(Document& doc, const MimeMessage& mime_msg) static void fill_document(Message::Private& priv) { + if (priv.document_filled) { + return; // nothing to do. + } + /* hunt & gather info from message tree */ Document& doc{priv.doc}; 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_reply_to(doc, mime_msg); /* only in sexp */ - field_for_each([&](auto&& field) { + field_for_each([&](const auto& field) { /* insist on explicitly handling each */ #pragma GCC diagnostic push #pragma GCC diagnostic error "-Wswitch" @@ -775,6 +783,8 @@ fill_document(Message::Private& priv) #pragma GCC diagnostic pop }); + + priv.document_filled = true; } Option