mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
Mail: Don't crash on invalid/missing From
Email header
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.
This commit is contained in:
parent
08fb98caac
commit
bdecb0a999
1 changed files with 11 additions and 4 deletions
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue