Skip to content

Commit 9bbc4f4

Browse files
committed
Normalize email local part to NFC
1 parent 574f7d8 commit 9bbc4f4

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@
107107
108108
output: '977577b140bfb7c516e4746204fbdb01',
109109
},
110+
{
111+
input: "bu\u0308[email protected]",
112+
output: '53550c712b146287a2d0dd30e5ed6f4b',
113+
},
114+
{
115+
input: "b\u00FC[email protected]",
116+
output: '53550c712b146287a2d0dd30e5ed6f4b',
117+
},
110118
]
111119

112120
tests.each do |i|

0 commit comments

Comments
 (0)