From f5335980825197a5711d51e3545b69f246de6c28 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 8 Oct 2021 13:18:37 +0100 Subject: [PATCH] [Minor] Require either by or from parts in received headers --- src/libmime/received.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libmime/received.cxx b/src/libmime/received.cxx index 0ff52da5a..6ba2cd678 100644 --- a/src/libmime/received.cxx +++ b/src/libmime/received.cxx @@ -253,6 +253,7 @@ received_spill(const std::string_view &in, { std::vector parts; std::ptrdiff_t pos = 0; + auto seen_from = false, seen_by = false; const auto *p = in.data(); const auto *end = p + in.size(); @@ -289,6 +290,7 @@ received_spill(const std::string_view &in, g_assert (pos != 0); p += pos; len = end > p ? end - p : 0; + seen_from = true; } if (len > 2 && lit_compare_lowercase<2>("by", p)) { @@ -301,6 +303,12 @@ received_spill(const std::string_view &in, g_assert (pos != 0); p += pos; len = end > p ? end - p : 0; + seen_by = true; + } + + if (!seen_from && !seen_by) { + /* Useless received */ + return {}; } while (p < end) { -- 2.39.5