OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/dns_util.h" | 5 #include "net/base/dns_util.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ret += "."; | 73 ret += "."; |
74 | 74 |
75 if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size()) | 75 if (static_cast<unsigned>(domain[i]) + i + 1 > domain.size()) |
76 return std::string(); | 76 return std::string(); |
77 | 77 |
78 domain.substr(i + 1, domain[i]).AppendToString(&ret); | 78 domain.substr(i + 1, domain[i]).AppendToString(&ret); |
79 } | 79 } |
80 return ret; | 80 return ret; |
81 } | 81 } |
82 | 82 |
83 bool IsSTD3ASCIIValidCharacter(char c) { | |
84 if (c <= 0x2c) | |
85 return false; | |
86 if (c >= 0x7b) | |
87 return false; | |
88 if (c >= 0x2e && c <= 0x2f) | |
89 return false; | |
90 if (c >= 0x3a && c <= 0x40) | |
91 return false; | |
92 if (c >= 0x5b && c <= 0x60) | |
93 return false; | |
94 return true; | |
95 } | |
96 | |
97 std::string TrimEndingDot(const base::StringPiece& host) { | 83 std::string TrimEndingDot(const base::StringPiece& host) { |
98 base::StringPiece host_trimmed = host; | 84 base::StringPiece host_trimmed = host; |
99 size_t len = host_trimmed.length(); | 85 size_t len = host_trimmed.length(); |
100 if (len > 1 && host_trimmed[len - 1] == '.') { | 86 if (len > 1 && host_trimmed[len - 1] == '.') { |
101 host_trimmed.remove_suffix(1); | 87 host_trimmed.remove_suffix(1); |
102 } | 88 } |
103 return host_trimmed.as_string(); | 89 return host_trimmed.as_string(); |
104 } | 90 } |
105 | 91 |
106 } // namespace net | 92 } // namespace net |
OLD | NEW |