Skip to content

Commit

Permalink
Mail: Don't crash on invalid/missing From Email header
Browse files Browse the repository at this point in the history
During testing, I found that some Email clients/providers format the
From header field content with a lower case f, so `from:` instead of
`From:`. Our client previously gave up if it couldn't find one that
starts with a capital F. Now, we try both, and provide a fallback if
neither were found.
  • Loading branch information
vkoskiv authored and ADKaster committed Aug 12, 2023
1 parent 08fb98c commit bdecb0a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Userland/Applications/Mail/MailWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,17 @@ void MailWidget::selected_mailbox()

auto& from_iterator_value = from_iterator->get<1>().value();
auto from_index = from_iterator_value.find("From:"sv);
VERIFY(from_index.has_value());
auto potential_from = from_iterator_value.substring(from_index.value());
auto from_parts = potential_from.split_limit(':', 2);
auto from = parse_and_unfold(from_parts.last());
if (!from_index.has_value())
from_index = from_iterator_value.find("from:"sv);
DeprecatedString from;
if (from_index.has_value()) {
auto potential_from = from_iterator_value.substring(from_index.value());
auto from_parts = potential_from.split_limit(':', 2);
from = parse_and_unfold(from_parts.last());
}

if (from.is_empty())
from = "(Unknown sender)";

InboxEntry inbox_entry { from, subject };

Expand Down

0 comments on commit bdecb0a

Please sign in to comment.