File tree Expand file tree Collapse file tree
main/java/com/maxmind/minfraud/request
test/java/com/maxmind/minfraud/request Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ CHANGELOG
2929 used. For example, ` gmali.com ` will become ` gmail.com ` .
3030* When ` hashAddress ` is used, all trailing periods are now removed from an
3131 email address domain. Previously only a single period was removed.
32+ * When ` hashAddress ` is used, the local part of an email address is now
33+ normalized to NFC.
3234
33353.3.0 (2023-12-05)
3436------------------
Original file line number Diff line number Diff line change 77import java .nio .charset .StandardCharsets ;
88import java .security .MessageDigest ;
99import java .security .NoSuchAlgorithmException ;
10+ import java .text .Normalizer ;
1011import java .util .Arrays ;
1112import java .util .Collections ;
1213import java .util .HashMap ;
@@ -422,6 +423,7 @@ private String cleanAddress(String address) {
422423 String localPart = address .substring (0 , domainIndex );
423424 String domain = address .substring (domainIndex + 1 );
424425
426+ localPart = Normalizer .normalize (localPart , Normalizer .Form .NFC );
425427 domain = cleanDomain (domain );
426428
427429 int stopChar ;
Original file line number Diff line number Diff line change @@ -223,6 +223,16 @@ public void testNormalizing() throws NoSuchAlgorithmException {
223223 e = new Builder (false ).address ("foo@example.com..." ).hashAddress ().build ();
224224 assertEquals (toMD5 ("foo@example.com" ), e .getAddress (), "MD5" );
225225 assertEquals ("example.com..." , e .getDomain (), "domain" );
226+
227+ e = new Builder ().address ("example@bu\u0308 cher.com" ).hashAddress ().build ();
228+ assertEquals ("2b21bc76dab3c8b1622837c1d698936c" , e .getAddress (), "MD5" );
229+ e = new Builder ().address ("example@b\u00FC cher.com" ).hashAddress ().build ();
230+ assertEquals ("2b21bc76dab3c8b1622837c1d698936c" , e .getAddress (), "MD5" );
231+
232+ e = new Builder ().address ("bu\u0308 cher@example.com" ).hashAddress ().build ();
233+ assertEquals ("53550c712b146287a2d0dd30e5ed6f4b" , e .getAddress (), "MD5" );
234+ e = new Builder ().address ("b\u00FC cher@example.com" ).hashAddress ().build ();
235+ assertEquals ("53550c712b146287a2d0dd30e5ed6f4b" , e .getAddress (), "MD5" );
226236 }
227237
228238 private String toMD5 (String s ) throws NoSuchAlgorithmException {
You can’t perform that action at this time.
0 commit comments