[geary] Don't flag a mailbox address without a distinct name as spoofed.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Don't flag a mailbox address without a distinct name as spoofed.
- Date: Thu, 1 Feb 2018 14:35:42 +0000 (UTC)
commit f8ef491cca82b5fca43c1e33a9e469e1cb02f132
Author: Michael James Gratton <mike vee net>
Date: Fri Feb 2 01:05:24 2018 +1030
Don't flag a mailbox address without a distinct name as spoofed.
This fixes annoying, albeit legit addresses like "mike vee net
<mike vee net>" from being flagged.
Followup to commit b7eea857.
* src/engine/rfc822/rfc822-mailbox-address.vala (MailboxAddress): Don't
test name for spoofyness if it's not distinct. Add unit test.
src/engine/rfc822/rfc822-mailbox-address.vala | 5 +++--
test/engine/rfc822-mailbox-address-test.vala | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/rfc822/rfc822-mailbox-address.vala b/src/engine/rfc822/rfc822-mailbox-address.vala
index 218753d..75e77fe 100644
--- a/src/engine/rfc822/rfc822-mailbox-address.vala
+++ b/src/engine/rfc822/rfc822-mailbox-address.vala
@@ -298,11 +298,12 @@ public class Geary.RFC822.MailboxAddress :
bool is_spoof = false;
// 1. Check the name part contains no controls and doesn't
- // look like an email address
+ // look like an email address (unless it's the same as the
+ // address part).
if (!Geary.String.is_empty(this.name)) {
if (Regex.match_simple(CONTROLS, this.name)) {
is_spoof = true;
- } else {
+ } else if (has_distinct_name()) {
// Clean up the name as usual, but remove all
// whitespace so an attack can't get away with a name
// like "potus @ whitehouse . gov"
diff --git a/test/engine/rfc822-mailbox-address-test.vala b/test/engine/rfc822-mailbox-address-test.vala
index 964d977..8426c0e 100644
--- a/test/engine/rfc822-mailbox-address-test.vala
+++ b/test/engine/rfc822-mailbox-address-test.vala
@@ -156,6 +156,7 @@ class Geary.RFC822.MailboxAddressTest : Gee.TestCase {
assert(new MailboxAddress("test test", "example example com").is_spoofed() == false);
assert(new MailboxAddress("test test", "example example com").is_spoofed() == false);
assert(new MailboxAddress("test?", "example example com").is_spoofed() == false);
+ assert(new MailboxAddress("test example com", "test example com").is_spoofed() == false);
assert(new MailboxAddress("test example com", "example example com").is_spoofed() == true);
assert(new MailboxAddress("test @ example . com", "example example com").is_spoofed() == true);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]