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

Side by Side Diff: net/base/dns_util.cc

Issue 6500010: HSTS: add net-internals UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 if (namelen + 1 > sizeof name) 51 if (namelen + 1 > sizeof name)
52 return false; 52 return false;
53 name[namelen++] = 0; // This is the root label (of length 0). 53 name[namelen++] = 0; // This is the root label (of length 0).
54 54
55 *out = std::string(name, namelen); 55 *out = std::string(name, namelen);
56 return true; 56 return true;
57 } 57 }
58 58
59 std::string DNSDomainToString(const std::string& domain) {
60 std::string ret;
61
62 for (unsigned i = 0; domain[i]; i += domain[i] + 1) {
eroman 2011/02/16 20:12:45 I am concerned about bounds checking in this funct
agl 2011/02/16 22:46:22 This function assumes that the input is in DNS for
63 if (i)
64 ret += ".";
65 ret += domain.substr(i + 1, domain[i]);
66 }
67 return ret;
68 }
69
59 bool IsSTD3ASCIIValidCharacter(char c) { 70 bool IsSTD3ASCIIValidCharacter(char c) {
60 if (c <= 0x2c) 71 if (c <= 0x2c)
61 return false; 72 return false;
62 if (c >= 0x7b) 73 if (c >= 0x7b)
63 return false; 74 return false;
64 if (c >= 0x2e && c <= 0x2f) 75 if (c >= 0x2e && c <= 0x2f)
65 return false; 76 return false;
66 if (c >= 0x3a && c <= 0x40) 77 if (c >= 0x3a && c <= 0x40)
67 return false; 78 return false;
68 if (c >= 0x5b && c <= 0x60) 79 if (c >= 0x5b && c <= 0x60)
69 return false; 80 return false;
70 return true; 81 return true;
71 } 82 }
72 83
73 std::string TrimEndingDot(const std::string& host) { 84 std::string TrimEndingDot(const std::string& host) {
74 std::string host_trimmed = host; 85 std::string host_trimmed = host;
75 size_t len = host_trimmed.length(); 86 size_t len = host_trimmed.length();
76 if (len > 1 && host_trimmed[len - 1] == '.') 87 if (len > 1 && host_trimmed[len - 1] == '.')
77 host_trimmed.erase(len - 1); 88 host_trimmed.erase(len - 1);
78 return host_trimmed; 89 return host_trimmed;
79 } 90 }
80 91
81 } // namespace net 92 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698