| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/quic/platform/impl/quic_hostname_utils_impl.h" | 5 #include "net/quic/platform/impl/quic_hostname_utils_impl.h" |
| 6 | 6 |
| 7 #include "net/base/url_util.h" | 7 #include "net/base/url_util.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 #include "url/url_canon.h" | 9 #include "url/url_canon.h" |
| 10 | 10 |
| 11 using base::StringPiece; | |
| 12 using std::string; | 11 using std::string; |
| 13 | 12 |
| 14 namespace net { | 13 namespace net { |
| 15 | 14 |
| 16 // static | 15 // static |
| 17 bool QuicHostnameUtilsImpl::IsValidSNI(StringPiece sni) { | 16 bool QuicHostnameUtilsImpl::IsValidSNI(QuicStringPiece sni) { |
| 18 // TODO(rtenneti): Support RFC2396 hostname. | 17 // TODO(rtenneti): Support RFC2396 hostname. |
| 19 // NOTE: Microsoft does NOT enforce this spec, so if we throw away hostnames | 18 // NOTE: Microsoft does NOT enforce this spec, so if we throw away hostnames |
| 20 // based on the above spec, we may be losing some hostnames that windows | 19 // based on the above spec, we may be losing some hostnames that windows |
| 21 // would consider valid. By far the most common hostname character NOT | 20 // would consider valid. By far the most common hostname character NOT |
| 22 // accepted by the above spec is '_'. | 21 // accepted by the above spec is '_'. |
| 23 url::CanonHostInfo host_info; | 22 url::CanonHostInfo host_info; |
| 24 string canonicalized_host(CanonicalizeHost(sni.as_string(), &host_info)); | 23 string canonicalized_host(CanonicalizeHost(sni.as_string(), &host_info)); |
| 25 return !host_info.IsIPAddress() && | 24 return !host_info.IsIPAddress() && |
| 26 IsCanonicalizedHostCompliant(canonicalized_host) && | 25 IsCanonicalizedHostCompliant(canonicalized_host) && |
| 27 sni.find_last_of('.') != string::npos; | 26 sni.find_last_of('.') != string::npos; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 if (!url.is_valid()) { | 55 if (!url.is_valid()) { |
| 57 *out = QuicServerId(); | 56 *out = QuicServerId(); |
| 58 return; | 57 return; |
| 59 } | 58 } |
| 60 *out = QuicServerId(HostPortPair::FromURL(url), url.path_piece() == "/private" | 59 *out = QuicServerId(HostPortPair::FromURL(url), url.path_piece() == "/private" |
| 61 ? PRIVACY_MODE_ENABLED | 60 ? PRIVACY_MODE_ENABLED |
| 62 : PRIVACY_MODE_DISABLED); | 61 : PRIVACY_MODE_DISABLED); |
| 63 } | 62 } |
| 64 | 63 |
| 65 } // namespace net | 64 } // namespace net |
| OLD | NEW |