Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Side by Side Diff: components/url_formatter/url_formatter_unittest.cc

Issue 2784933002: Mitigate spoofing attempt using Latin letters. (Closed)
Patch Set: use checked_cast and make win64 happy Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/url_formatter/url_formatter.h" 5 #include "components/url_formatter/url_formatter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 L"\x0455\x0441\x043e\x0440\x0435\u00b7\x0440\x0430\x0443.\x0440\x0444", 293 L"\x0455\x0441\x043e\x0440\x0435\u00b7\x0440\x0430\x0443.\x0440\x0444",
294 true}, 294 true},
295 295
296 // ѕсоре-рау.한국 with ѕсоре and рау in Cyrillic. 296 // ѕсоре-рау.한국 with ѕсоре and рау in Cyrillic.
297 {"xn----8sbn9akccw8m.xn--3e0b707e", 297 {"xn----8sbn9akccw8m.xn--3e0b707e",
298 L"\x0455\x0441\x043e\x0440\x0435-\x0440\x0430\x0443.\xd55c\xad6d", true}, 298 L"\x0455\x0441\x043e\x0440\x0435-\x0440\x0430\x0443.\xd55c\xad6d", true},
299 299
300 // музей (museum in Russian) has characters without a Latin-look-alike. 300 // музей (museum in Russian) has characters without a Latin-look-alike.
301 {"xn--e1adhj9a.com", L"\x043c\x0443\x0437\x0435\x0439.com", true}, 301 {"xn--e1adhj9a.com", L"\x043c\x0443\x0437\x0435\x0439.com", true},
302 302
303 // Combining Diacritic marks after a script other than Latin-Greek-Cyrillic
304 {"xn--rsa2568fvxya.com", L"\xd55c\x0301\xae00.com", false}, // 한́글.com
305 {"xn--rsa0336bjom.com", L"\x6f22\x0307\x5b57.com", false}, // 漢̇字.com
306 // नागरी́.com
307 {"xn--lsa922apb7a6do.com", L"\x0928\x093e\x0917\x0930\x0940\x0301.com",
308 false},
309
310 // Similarity checks against the list of top domains. "digklmo68.com" and
311 // 'digklmo68.co.uk" are listed for unittest in the top domain list.
312 {"xn--igklmo68-nea32c.com", L"\x0111igklmo68.com", false}, // đigklmo68.com
313 {"www.xn--igklmo68-nea32c.com", L"www.\x0111igklmo68.com", false},
314 {"foo.bar.xn--igklmo68-nea32c.com", L"foo.bar.\x0111igklmo68.com", false},
315 {"xn--igklmo68-nea32c.co.uk", L"\x0111igklmo68.co.uk", false},
316 {"mail.xn--igklmo68-nea32c.co.uk", L"mail.\x0111igklmo68.co.uk", false},
317 {"xn--digklmo68-6jf.com", L"di\x0307gklmo68.com", false}, // di̇gklmo68.com
318 {"xn--digklmo68-7vf.com", L"dig\x0331klmo68.com", false}, // dig̱klmo68.com
319 {"xn--diglmo68-omb.com", L"dig\x0138lmo68.com", false}, // digĸlmo68.com
320 {"xn--digkmo68-9ob.com", L"digk\x0142mo68.com", false}, // digkłmo68.com
321 {"xn--digklo68-l89c.com", L"digkl\x1e43o68.com", false}, // digklṃo68.com
322 {"xn--digklm68-b5a.com", L"digklm\x00f8" L"68.com", false}, // digklmø68.com
323 {"xn--digklmo8-h7g.com", L"digklmo\x0431" L"8.com", false}, // digklmoб8.com
324 {"xn--digklmo6-7yr.com", L"digklmo6\x09ea.com", false}, // digklmo6৪.com
325
326 // 'islkpx123.com' is listed for unitest in the top domain list.
327 // 'іѕӏкрх123' can look like 'islkpx123' in some fonts.
328 {"xn--123-bed4a4a6hh40i.com",
329 L"\x0456\x0455\x04cf\x043a\x0440\x0445" L"123.com", false},
330
303 // Mixed digits: the first two will also fail mixed script test 331 // Mixed digits: the first two will also fail mixed script test
304 // Latin + ASCII digit + Deva digit 332 // Latin + ASCII digit + Deva digit
305 {"xn--asc1deva-j0q.co.in", L"asc1deva\x0967.co.in", false}, 333 {"xn--asc1deva-j0q.co.in", L"asc1deva\x0967.co.in", false},
306 // Latin + Deva digit + Beng digit 334 // Latin + Deva digit + Beng digit
307 {"xn--devabeng-f0qu3f.co.in", L"deva\x0967" L"beng\x09e7.co.in", false}, 335 {"xn--devabeng-f0qu3f.co.in", L"deva\x0967" L"beng\x09e7.co.in", false},
308 // ASCII digit + Deva digit 336 // ASCII digit + Deva digit
309 {"xn--79-v5f.co.in", L"7\x09ea" L"9.co.in", false}, 337 {"xn--79-v5f.co.in", L"7\x09ea" L"9.co.in", false},
310 // Deva digit + Beng digit 338 // Deva digit + Beng digit
311 {"xn--e4b0x.co.in", L"\x0967\x09e7.co.in", false}, 339 {"xn--e4b0x.co.in", L"\x0967\x09e7.co.in", false},
312 // U+4E00 (CJK Ideograph One) is not a digit 340 // U+4E00 (CJK Ideograph One) is not a digit
(...skipping 13 matching lines...) Expand all
326 {"xn--58db0a9q.com", L"\x13df\x13aa\x13a1\x13a0.com", false}, 354 {"xn--58db0a9q.com", L"\x13df\x13aa\x13a1\x13a0.com", false},
327 // Scripts excluded from Identifiers: UTS 31 Table 4 355 // Scripts excluded from Identifiers: UTS 31 Table 4
328 // Coptic 356 // Coptic
329 {"xn--5ya.com", L"\x03e7.com", false}, 357 {"xn--5ya.com", L"\x03e7.com", false},
330 // Old Italic 358 // Old Italic
331 {"xn--097cc.com", L"\U00010300\U00010301.com", false}, 359 {"xn--097cc.com", L"\U00010300\U00010301.com", false},
332 360
333 // U+115F (Hangul Filler) 361 // U+115F (Hangul Filler)
334 {"xn--osd3820f24c.kr", L"\xac00\xb098\x115f.kr", false}, 362 {"xn--osd3820f24c.kr", L"\xac00\xb098\x115f.kr", false},
335 {"www.xn--google-ho0coa.com", L"www.\x2039google\x203a.com", false}, 363 {"www.xn--google-ho0coa.com", L"www.\x2039google\x203a.com", false},
336 // Latin small capital w 364 // Latin small capital w: hardᴡare.com
337 {"xn--hardare-l41c.com", L"hard\x1d21" L"are.com", false}, 365 {"xn--hardare-l41c.com", L"hard\x1d21" L"are.com", false},
338 // Minus Sign(U+2212) 366 // Minus Sign(U+2212)
339 {"xn--t9g238xc2a.jp", L"\x65e5\x2212\x672c.jp", false}, 367 {"xn--t9g238xc2a.jp", L"\x65e5\x2212\x672c.jp", false},
340 // Latin Small Letter Script G 368 // Latin Small Letter Script G: ɡɡ.com
341 {"xn--0naa.com", L"\x0261\x0261.com", false}, 369 {"xn--0naa.com", L"\x0261\x0261.com", false},
342 // Hangul Jamo(U+11xx) 370 // Hangul Jamo(U+11xx)
343 {"xn--0pdc3b.com", L"\x1102\x1103\x1110.com", false}, 371 {"xn--0pdc3b.com", L"\x1102\x1103\x1110.com", false},
344 // degree sign 372 // degree sign: 36°c.com
345 {"xn--36c-tfa.com", L"36\x00b0" L"c.com", false}, 373 {"xn--36c-tfa.com", L"36\x00b0" L"c.com", false},
346 // Pound sign 374 // Pound sign
347 {"xn--5free-9ga.com", L"5free\x00a8.com", false}, 375 {"xn--5free-9ga.com", L"5free\x00a8.com", false},
348 // Hebrew points (U+05B0, U+05B6) 376 // Hebrew points (U+05B0, U+05B6)
349 {"xn--7cbl2kc2a.com", L"\x05e1\x05b6\x05e7\x05b0\x05e1.com", false}, 377 {"xn--7cbl2kc2a.com", L"\x05e1\x05b6\x05e7\x05b0\x05e1.com", false},
350 // Danda(U+0964) 378 // Danda(U+0964)
351 {"xn--81bp1b6ch8s.com", L"\x0924\x093f\x091c\x0964\x0930\x0940.com", false}, 379 {"xn--81bp1b6ch8s.com", L"\x0924\x093f\x091c\x0964\x0930\x0940.com", false},
352 // Small letter script G(U+0261) 380 // Small letter script G(U+0261)
353 {"xn--oogle-qmc.com", L"\x0261oogle.com", false}, 381 {"xn--oogle-qmc.com", L"\x0261oogle.com", false},
354 // Small Katakana Extension(U+31F1) 382 // Small Katakana Extension(U+31F1)
355 {"xn--wlk.com", L"\x31f1.com", false}, 383 {"xn--wlk.com", L"\x31f1.com", false},
356 // Heart symbol 384 // Heart symbol: ♥
357 {"xn--ab-u0x.com", L"ab\x2665.com", false}, 385 {"xn--ab-u0x.com", L"ab\x2665.com", false},
358 // Emoji 386 // Emoji
359 {"xn--vi8hiv.xyz", L"\U0001f355\U0001f4a9.xyz", false}, 387 {"xn--vi8hiv.xyz", L"\U0001f355\U0001f4a9.xyz", false},
360 // Registered trade mark 388 // Registered trade mark
361 {"xn--egistered-fna.com", L"\x00ae" L"egistered.com", false}, 389 {"xn--egistered-fna.com", L"\x00ae" L"egistered.com", false},
362 // Latin Letter Retroflex Click 390 // Latin Letter Retroflex Click
363 {"xn--registered-25c.com", L"registered\x01c3.com", false}, 391 {"xn--registered-25c.com", L"registered\x01c3.com", false},
364 // ASCII '!' not allowed in IDN 392 // ASCII '!' not allowed in IDN
365 {"xn--!-257eu42c.kr", L"\xc548\xb155!.kr", false}, 393 {"xn--!-257eu42c.kr", L"\xc548\xb155!.kr", false},
366 // 'GOOGLE' in IPA extension 394 // 'GOOGLE' in IPA extension: ɢᴏᴏɢʟᴇ
367 {"xn--1naa7pn51hcbaa.com", 395 {"xn--1naa7pn51hcbaa.com",
368 L"\x0262\x1d0f\x1d0f\x0262\x029f\x1d07.com", false}, 396 L"\x0262\x1d0f\x1d0f\x0262\x029f\x1d07.com", false},
369 // Padlock icon spoof. 397 // Padlock icon spoof.
370 {"xn--google-hj64e", L"\U0001f512google.com", false}, 398 {"xn--google-hj64e", L"\U0001f512google.com", false},
371 399
372 // Custom black list 400 // Custom black list
373 // Combining Long Solidus Overlay 401 // Combining Long Solidus Overlay
374 {"google.xn--comabc-k8d", L"google.com\x0338" L"abc", false}, 402 {"google.xn--comabc-k8d", L"google.com\x0338" L"abc", false},
375 // Hyphenation Point instead of Katakana Middle dot 403 // Hyphenation Point instead of Katakana Middle dot
376 {"xn--svgy16dha.jp", L"\x30a1\x2027\x30a3.jp", false}, 404 {"xn--svgy16dha.jp", L"\x30a1\x2027\x30a3.jp", false},
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos, 1044 0, kNpos, kNpos, kNpos, kNpos, kNpos, kNpos, 0, kNpos, kNpos, kNpos, kNpos,
1017 0, 1, 2, 3, 4, 5, 6, 7 1045 0, 1, 2, 3, 4, 5, 6, 7
1018 }; 1046 };
1019 CheckAdjustedOffsets("http://user@foo.com/", kFormatUrlOmitAll, 1047 CheckAdjustedOffsets("http://user@foo.com/", kFormatUrlOmitAll,
1020 net::UnescapeRule::NORMAL, omit_all_offsets); 1048 net::UnescapeRule::NORMAL, omit_all_offsets);
1021 } 1049 }
1022 1050
1023 } // namespace 1051 } // namespace
1024 1052
1025 } // namespace url_formatter 1053 } // namespace url_formatter
OLDNEW
« no previous file with comments | « components/url_formatter/url_formatter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698