Skip to content

Commit

Permalink
Merge pull request #164 from maxmind/horgh/email-normalize-fix
Browse files Browse the repository at this point in the history
Fix issue where local part was changed incorrectly in hashEmail heuristics
  • Loading branch information
marselester authored Mar 4, 2024
2 parents 150fb00 + ba46594 commit 26e43ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MinFraud/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ private static function hashEmail(string $localPart, string $domain): string
$possibleDomain = implode('.', \array_slice($domainParts, 1));
if (isset(self::$fastmailDomains[$possibleDomain])) {
$domain = $possibleDomain;
}
if ($localPart !== '') {
$localPart = $domainParts[0];
if ($localPart !== '') {
$localPart = $domainParts[0];
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions tests/MaxMind/Test/MinFraud/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ public function testMaybeHashEmail(): void
],
],
],
[
'name' => 'Domain with multiple host parts',
'input' => ['email' => ['address' => '[email protected]']],
'expected' => [
'email' => [
'address' => md5('[email protected]'),
'domain' => 'bar.example.com',
],
],
],
[
'name' => 'Yahoo domain',
'input' => ['email' => ['address' => '[email protected]']],
Expand Down

0 comments on commit 26e43ea

Please sign in to comment.