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

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

Issue 2595723003: url_formatter: Update comments for clarity. (Closed)
Patch Set: Rebase. Created 3 years, 10 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
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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 // Miao 452 // Miao
453 "\\U00016F00-\\U00016F44\\U00016F50-\\U00016F7E" 453 "\\U00016F00-\\U00016F44\\U00016F50-\\U00016F7E"
454 "\\U00016F8F-\\U00016F9F]", 454 "\\U00016F8F-\\U00016F9F]",
455 -1, US_INV), 455 -1, US_INV),
456 *status); 456 *status);
457 allowed_set.addAll(aspirational_scripts); 457 allowed_set.addAll(aspirational_scripts);
458 #else 458 #else
459 #error "Update aspirational_scripts per Unicode 10.0" 459 #error "Update aspirational_scripts per Unicode 10.0"
460 #endif 460 #endif
461 461
462 // U+0338 is included in the recommended set, while U+05F4 and U+2027 are in 462 // The sections below refer to Mozilla's IDN blacklist:
463 // the inclusion set. However, they are blacklisted as a part of Mozilla's 463 // http://kb.mozillazine.org/Network.IDN.blacklist_chars
464 // IDN blacklist (http://kb.mozillazine.org/Network.IDN.blacklist_chars). 464 //
465 // U+2010 is in the inclusion set, but we drop it because it can be confused 465 // U+0338 (Combining Long Solidus Overlay) is included in the recommended set,
466 // with an ASCII U+002D (Hyphen-Minus). 466 // but is blacklisted by Mozilla. It is dropped because it can look like a
467 // U+0338 and U+2027 are dropped; the former can look like a slash when 467 // slash when rendered with a broken font.
468 // rendered with a broken font, and the latter can be confused with U+30FB 468 allowed_set.remove(0x338u);
469 // (Katakana Middle Dot). U+05F4 (Hebrew Punctuation Gershayim) is kept, 469 // U+05F4 (Hebrew Punctuation Gershayim) is in the inclusion set, but is
470 // even though it can look like a double quotation mark. Using it in Hebrew 470 // blacklisted by Mozilla. We keep it, even though it can look like a double
471 // should be safe. When used with a non-Hebrew script, it'd be filtered by 471 // quotation mark. Using it in Hebrew should be safe. When used with a
472 // other checks in place. 472 // non-Hebrew script, it'd be filtered by other checks in place.
473 allowed_set.remove(0x338u); // Combining Long Solidus Overlay 473 //
474 allowed_set.remove(0x2010u); // Hyphen 474 // U+2010 (Hyphen) is in the inclusion set, but we drop it because it can be
475 allowed_set.remove(0x2027u); // Hyphenation Point 475 // confused with an ASCII U+002D (Hyphen-Minus).
476 allowed_set.remove(0x2010u);
477 // U+2027 (Hyphenation Point) is in the inclusion set, but is blacklisted by
478 // Mozilla. It is dropped, as it can be confused with U+30FB (Katakana Middle
479 // Dot).
480 allowed_set.remove(0x2027u);
476 481
477 uspoof_setAllowedUnicodeSet(checker_, &allowed_set, status); 482 uspoof_setAllowedUnicodeSet(checker_, &allowed_set, status);
478 } 483 }
479 484
480 // Returns true if the given Unicode host component is safe to display to the 485 // Returns true if the given Unicode host component is safe to display to the
481 // user. Note that this function does not deal with pure ASCII domain labels at 486 // user. Note that this function does not deal with pure ASCII domain labels at
482 // all even though it's possible to make up look-alike labels with ASCII 487 // all even though it's possible to make up look-alike labels with ASCII
483 // characters alone. 488 // characters alone.
484 bool IsIDNComponentSafe(base::StringPiece16 label) { 489 bool IsIDNComponentSafe(base::StringPiece16 label) {
485 return g_idn_spoof_checker.Get().Check(label); 490 return g_idn_spoof_checker.Get().Check(label);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 return base::StartsWith(text, www, base::CompareCase::SENSITIVE) 804 return base::StartsWith(text, www, base::CompareCase::SENSITIVE)
800 ? text.substr(www.length()) : text; 805 ? text.substr(www.length()) : text;
801 } 806 }
802 807
803 base::string16 StripWWWFromHost(const GURL& url) { 808 base::string16 StripWWWFromHost(const GURL& url) {
804 DCHECK(url.is_valid()); 809 DCHECK(url.is_valid());
805 return StripWWW(base::ASCIIToUTF16(url.host_piece())); 810 return StripWWW(base::ASCIIToUTF16(url.host_piece()));
806 } 811 }
807 812
808 } // namespace url_formatter 813 } // namespace url_formatter
OLDNEW
« no previous file with comments | « no previous file | components/url_formatter/url_formatter_unittest.cc » ('j') | components/url_formatter/url_formatter_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698