Browse Source

[Minor] Fix parsing received that start from a comment

tags/3.1
Vsevolod Stakhov 2 years ago
parent
commit
de4454e5e1
1 changed files with 37 additions and 0 deletions
  1. 37
    0
      src/libmime/received.cxx

+ 37
- 0
src/libmime/received.cxx View File

@@ -258,12 +258,41 @@ received_spill(const std::string_view &in,
const auto *p = in.data();
const auto *end = p + in.size();

/* Skip spaces */
while (p < end && g_ascii_isspace (*p)) {
p++;
}

/* And SMTP comments */
if (*p == '(') {
auto obraces = 0, ebraces = 0;

while (p < end) {
if (*p == ')') {
ebraces ++;
}
else if (*p == '(') {
obraces ++;
}

p ++;

if (obraces == ebraces) {
/* Skip spaces after */
while (p < end && g_ascii_isspace (*p)) {
p++;
}
break;
}
}
}

auto len = end - p;

if (len == 0) {
return {};
}

auto maybe_process_part = [&](received_part_type what) -> bool {
parts.emplace_back(what);
auto &rcvd_part = parts.back();
@@ -1003,6 +1032,14 @@ TEST_CASE("parse received")
{"by_hostname", "mail.832zsu.cn"},
}
},
// From part is in the comment
{"(from asterisk@localhost)\n"
" by pbx.xxx.com (8.14.7/8.14.7/Submit) id 076Go4wD014562;\n"
" Thu, 6 Aug 2020 11:50:04 -0500"sv,
{
{"by_hostname", "pbx.xxx.com"},
}
},
};
rspamd_mempool_t *pool = rspamd_mempool_new_default("rcvd test", 0);


Loading…
Cancel
Save