OLD | NEW |
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 "net/cert/internal/verify_name_match.h" | 5 #include "net/cert/internal/verify_name_match.h" |
6 | 6 |
| 7 #include "base/strings/string_util.h" |
7 #include "base/tuple.h" | 8 #include "base/tuple.h" |
8 #include "net/cert/internal/parse_name.h" | 9 #include "net/cert/internal/parse_name.h" |
9 #include "net/der/input.h" | 10 #include "net/der/input.h" |
10 #include "net/der/parser.h" | 11 #include "net/der/parser.h" |
11 #include "net/der/tag.h" | 12 #include "net/der/tag.h" |
12 | 13 |
13 namespace net { | 14 namespace net { |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 73 |
73 for (; read_iter != output->end(); ++read_iter) { | 74 for (; read_iter != output->end(); ++read_iter) { |
74 const unsigned char c = *read_iter; | 75 const unsigned char c = *read_iter; |
75 if (c == ' ') { | 76 if (c == ' ') { |
76 // If there are non-whitespace characters remaining in input, compress | 77 // If there are non-whitespace characters remaining in input, compress |
77 // multiple whitespace chars to a single space, otherwise ignore trailing | 78 // multiple whitespace chars to a single space, otherwise ignore trailing |
78 // whitespace. | 79 // whitespace. |
79 std::string::const_iterator next_iter = read_iter + 1; | 80 std::string::const_iterator next_iter = read_iter + 1; |
80 if (next_iter != output->end() && *next_iter != ' ') | 81 if (next_iter != output->end() && *next_iter != ' ') |
81 *(write_iter++) = ' '; | 82 *(write_iter++) = ' '; |
82 } else if (c >= 'A' && c <= 'Z') { | 83 } else if (base::IsAsciiUpper(c)) { |
83 // Fold case. | 84 // Fold case. |
84 *(write_iter++) = c + ('a' - 'A'); | 85 *(write_iter++) = c + ('a' - 'A'); |
85 } else { | 86 } else { |
86 // Note that these checks depend on the characters allowed by earlier | 87 // Note that these checks depend on the characters allowed by earlier |
87 // conditions also being valid for the enforced charset. | 88 // conditions also being valid for the enforced charset. |
88 switch (charset_enforcement) { | 89 switch (charset_enforcement) { |
89 case ENFORCE_PRINTABLE_STRING: | 90 case ENFORCE_PRINTABLE_STRING: |
90 // See NormalizePrintableStringValue comment for the acceptable list | 91 // See NormalizePrintableStringValue comment for the acceptable list |
91 // of characters. | 92 // of characters. |
92 if (!((c >= 'a' && c <= 'z') || (c >= '\'' && c <= ':') || c == '=' || | 93 if (!(base::IsAsciiLower(c) || (c >= '\'' && c <= ':') || c == '=' || |
93 c == '?')) | 94 c == '?')) |
94 return false; | 95 return false; |
95 break; | 96 break; |
96 case ENFORCE_ASCII: | 97 case ENFORCE_ASCII: |
97 if (c > 0x7F) | 98 if (c > 0x7F) |
98 return false; | 99 return false; |
99 break; | 100 break; |
100 case NO_ENFORCEMENT: | 101 case NO_ENFORCEMENT: |
101 break; | 102 break; |
102 } | 103 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 return true; | 313 return true; |
313 } | 314 } |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 *contained_email_address = false; | 318 *contained_email_address = false; |
318 return true; | 319 return true; |
319 } | 320 } |
320 | 321 |
321 } // namespace net | 322 } // namespace net |
OLD | NEW |