OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/parse_name.h" | 5 #include "net/cert/internal/parse_name.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversion_utils.h" | 10 #include "base/strings/utf_string_conversion_utils.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/sys_byteorder.h" | 12 #include "base/sys_byteorder.h" |
13 #include "base/third_party/icu/icu_utf.h" | 13 #include "base/third_party/icu/icu_utf.h" |
14 | 14 |
15 #if !defined(OS_NACL) | |
16 #include "net/base/net_string_util.h" | |
17 #endif | |
18 | |
15 namespace net { | 19 namespace net { |
16 | 20 |
17 namespace { | 21 namespace { |
18 | 22 |
19 // Converts a BMPString value in Input |in| to UTF-8. | 23 // Converts a BMPString value in Input |in| to UTF-8. |
20 // | 24 // |
21 // If the conversion is successful, returns true and stores the result in | 25 // If the conversion is successful, returns true and stores the result in |
22 // |out|. Otherwise it returns false and leaves |out| unmodified. | 26 // |out|. Otherwise it returns false and leaves |out| unmodified. |
23 bool ConvertBmpStringValue(const der::Input& in, std::string* out) { | 27 bool ConvertBmpStringValue(const der::Input& in, std::string* out) { |
24 if (in.Length() % 2 != 0) | 28 if (in.Length() % 2 != 0) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 der::Input TypeDomainComponentOid() { | 189 der::Input TypeDomainComponentOid() { |
186 // dc (domainComponent): 0.9.2342.19200300.100.1.25 (RFC 4519) | 190 // dc (domainComponent): 0.9.2342.19200300.100.1.25 (RFC 4519) |
187 static const uint8_t oid[] = {0x09, 0x92, 0x26, 0x89, 0x93, | 191 static const uint8_t oid[] = {0x09, 0x92, 0x26, 0x89, 0x93, |
188 0xF2, 0x2C, 0x64, 0x01, 0x19}; | 192 0xF2, 0x2C, 0x64, 0x01, 0x19}; |
189 return der::Input(oid); | 193 return der::Input(oid); |
190 } | 194 } |
191 | 195 |
192 bool X509NameAttribute::ValueAsString(std::string* out) const { | 196 bool X509NameAttribute::ValueAsString(std::string* out) const { |
193 switch (value_tag) { | 197 switch (value_tag) { |
194 case der::kTeletexString: | 198 case der::kTeletexString: |
195 for (char c : value.AsStringPiece()) { | 199 #if !defined(OS_NACL) |
196 if (c < 32 || c > 126) | 200 return ConvertToUtf8(value.AsString(), kCharsetLatin1, out); |
197 return false; | 201 #else |
198 } | 202 // For nacl, just fall through to treating like IA5String (ascii). |
eroman
2017/05/05 17:55:29
Why the difference for nacl?
mattm
2017/05/05 19:58:39
the net/ build for nacl doesn't include base/net_s
eroman
2017/05/05 20:07:07
It is unfortunate to have a different behavior her
mattm
2017/05/05 20:16:25
Done.
davidben
2017/05/12 16:47:26
FWIW, Latin1 doesn't need much code to convert to
| |
199 *out = value.AsString(); | 203 #endif |
200 return true; | |
201 case der::kIA5String: | 204 case der::kIA5String: |
202 for (char c : value.AsStringPiece()) { | 205 for (char c : value.AsStringPiece()) { |
203 if (static_cast<uint8_t>(c) > 127) | 206 if (static_cast<uint8_t>(c) > 127) |
204 return false; | 207 return false; |
205 } | 208 } |
206 *out = value.AsString(); | 209 *out = value.AsString(); |
207 return true; | 210 return true; |
208 case der::kPrintableString: | 211 case der::kPrintableString: |
209 for (char c : value.AsStringPiece()) { | 212 for (char c : value.AsStringPiece()) { |
210 if (!(base::IsAsciiAlpha(c) || c == ' ' || (c >= '\'' && c <= ':') || | 213 if (!(base::IsAsciiAlpha(c) || c == ' ' || (c >= '\'' && c <= ':') || |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 if (!rdns_string.empty()) | 381 if (!rdns_string.empty()) |
379 rdns_string += ","; | 382 rdns_string += ","; |
380 rdns_string += rdn_string; | 383 rdns_string += rdn_string; |
381 } | 384 } |
382 | 385 |
383 *out = rdns_string; | 386 *out = rdns_string; |
384 return true; | 387 return true; |
385 } | 388 } |
386 | 389 |
387 } // namespace net | 390 } // namespace net |
OLD | NEW |