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

Side by Side Diff: components/url_formatter/idn_spoof_checker.h

Issue 2877973003: Pull out IDN_Spoof_Checker to separate cc/h files. (Closed)
Patch Set: fix a typo in regex 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/BUILD.gn ('k') | components/url_formatter/idn_spoof_checker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_URL_FORMATTER_IDN_SPOOF_CHECKER_H_
6 #define COMPONENTS_URL_FORMATTER_IDN_SPOOF_CHECKER_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/strings/string16.h"
12 #include "base/strings/string_piece.h"
13 #include "third_party/icu/source/common/unicode/uniset.h"
14 #include "third_party/icu/source/common/unicode/utypes.h"
15 #include "third_party/icu/source/common/unicode/uversion.h"
16
17 // 'icu' does not work. Use U_ICU_NAMESPACE.
18 namespace U_ICU_NAMESPACE {
19
20 class UnicodeString;
21
22 } // namespace U_ICU_NAMESPACE
23
24 struct USpoofChecker;
25
26 namespace url_formatter {
27
28 // A helper class for IDN Spoof checking, used to ensure that no IDN input is
29 // spoofable per Chromium's standard of spoofability. For a more thorough
30 // explanation of how spoof checking works in Chromium, see
31 // http://dev.chromium.org/developers/design-documents/idn-in-google-chrome .
32
33 class IDNSpoofChecker {
34 public:
35 IDNSpoofChecker();
36 ~IDNSpoofChecker();
37
38 // Returns true if |label| is safe to display as Unicode. In the event of
39 // library failure, all IDN inputs will be treated as unsafe.
40 // See the function body for details on the specific safety checks performed.
41 bool SafeToDisplayAsUnicode(base::StringPiece16 label, bool is_tld_ascii);
42
43 private:
44 // Sets allowed characters in IDN labels and turns on USPOOF_CHAR_LIMIT.
45 void SetAllowedUnicodeSet(UErrorCode* status);
46 // Returns true if all the Cyrillic letters in |label| belong to a set of
47 // Cyrillic letters that look like ASCII Latin letters.
48 bool IsMadeOfLatinAlikeCyrillic(const icu::UnicodeString& label);
49
50 USpoofChecker* checker_;
51 icu::UnicodeSet deviation_characters_;
52 icu::UnicodeSet non_ascii_latin_letters_;
53 icu::UnicodeSet kana_letters_exceptions_;
54 icu::UnicodeSet cyrillic_letters_;
55 icu::UnicodeSet cyrillic_letters_latin_alike_;
56
57 IDNSpoofChecker(const IDNSpoofChecker&) = delete;
58 void operator=(const IDNSpoofChecker&) = delete;
59 };
60
61 } // namespace url_formatter
62
63 #endif // COMPONENTS_URL_FORMATTER_IDN_SPOOF_CHECKER_H_
OLDNEW
« no previous file with comments | « components/url_formatter/BUILD.gn ('k') | components/url_formatter/idn_spoof_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698