Skip to content

Commit 28a0fa5

Browse files
authored
Merge pull request #96 from maxmind/ugexe/email-nfc
Normalize email addresses to NFC
2 parents ea95d39 + 9bbc4f4 commit 28a0fa5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
used. For example, `gmali.com` will become `gmail.com`.
2727
* When `hash_address` is used, all trailing periods are now removed from an
2828
email address domain. Previously only a single period was removed.
29+
* When `hash_address` is used, the local part of an email address is now
30+
normalized to NFC.
2931

3032
## v2.4.0 (2024-01-12)
3133

lib/minfraud/components/email.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def clean_email_address(address)
8888
local_part, domain = address.split('@', 2)
8989
return nil if !local_part || !domain
9090

91+
local_part = local_part.unicode_normalize(:nfc)
92+
9193
domain = clean_domain(domain)
9294

9395
if YAHOO_DOMAINS.key?(domain)

spec/components/email_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
{ input: '[email protected]', output: '[email protected]' },
8383
{ input: '[email protected].', output: '[email protected]' },
8484
{ input: '[email protected]...', output: '[email protected]' },
85+
{ input: "example@bu\u0308cher.com", output: '[email protected]' },
86+
{ input: "example@b\u00FCcher.com", output: '[email protected]' },
8587
]
8688

8789
tests.each do |i|
@@ -105,6 +107,14 @@
105107
106108
output: '977577b140bfb7c516e4746204fbdb01',
107109
},
110+
{
111+
input: "bu\u0308[email protected]",
112+
output: '53550c712b146287a2d0dd30e5ed6f4b',
113+
},
114+
{
115+
input: "b\u00FC[email protected]",
116+
output: '53550c712b146287a2d0dd30e5ed6f4b',
117+
},
108118
]
109119

110120
tests.each do |i|

0 commit comments

Comments
 (0)