| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/net_util.h" | 5 #include "net/base/net_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 decoded->clear(); | 1232 decoded->clear(); |
| 1233 return true; | 1233 return true; |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 std::string unescaped = UnescapeURLComponent(value, | 1236 std::string unescaped = UnescapeURLComponent(value, |
| 1237 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); | 1237 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); |
| 1238 | 1238 |
| 1239 return base::ConvertToUtf8AndNormalize(unescaped, charset, decoded); | 1239 return base::ConvertToUtf8AndNormalize(unescaped, charset, decoded); |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 // TODO(mpcomplete): This is a quick and dirty implementation for now. I'm | |
| 1243 // sure this doesn't properly handle all (most?) cases. | |
| 1244 std::string GetHeaderParamValue(const std::string& header, | |
| 1245 const std::string& param_name, | |
| 1246 QuoteRule::Type quote_rule) { | |
| 1247 // This assumes args are formatted exactly like "bla; arg1=value; arg2=value". | |
| 1248 std::string::const_iterator param_begin = | |
| 1249 std::search(header.begin(), header.end(), param_name.begin(), | |
| 1250 param_name.end(), base::CaseInsensitiveCompareASCII<char>()); | |
| 1251 | |
| 1252 if (param_begin == header.end()) | |
| 1253 return std::string(); | |
| 1254 param_begin += param_name.length(); | |
| 1255 | |
| 1256 std::string whitespace(" \t"); | |
| 1257 size_t equals_offset = | |
| 1258 header.find_first_not_of(whitespace, param_begin - header.begin()); | |
| 1259 if (equals_offset == std::string::npos || header[equals_offset] != '=') | |
| 1260 return std::string(); | |
| 1261 | |
| 1262 size_t param_value_offset = | |
| 1263 header.find_first_not_of(whitespace, equals_offset + 1); | |
| 1264 if (param_value_offset == std::string::npos) | |
| 1265 return std::string(); | |
| 1266 | |
| 1267 param_begin = header.begin() + param_value_offset; | |
| 1268 if (param_begin == header.end()) | |
| 1269 return std::string(); | |
| 1270 | |
| 1271 std::string::const_iterator param_end; | |
| 1272 if (*param_begin == '"' && quote_rule == QuoteRule::REMOVE_OUTER_QUOTES) { | |
| 1273 ++param_begin; // skip past the quote. | |
| 1274 param_end = std::find(param_begin, header.end(), '"'); | |
| 1275 // If the closing quote is missing, we will treat the rest of the | |
| 1276 // string as the parameter. We can't set |param_end| to the | |
| 1277 // location of the separator (';'), since the separator is | |
| 1278 // technically quoted. See: http://crbug.com/58840 | |
| 1279 } else { | |
| 1280 param_end = std::find(param_begin + 1, header.end(), ';'); | |
| 1281 } | |
| 1282 | |
| 1283 return std::string(param_begin, param_end); | |
| 1284 } | |
| 1285 | |
| 1286 string16 IDNToUnicode(const std::string& host, | 1242 string16 IDNToUnicode(const std::string& host, |
| 1287 const std::string& languages) { | 1243 const std::string& languages) { |
| 1288 return IDNToUnicodeWithOffsets(host, languages, NULL); | 1244 return IDNToUnicodeWithOffsets(host, languages, NULL); |
| 1289 } | 1245 } |
| 1290 | 1246 |
| 1291 std::string CanonicalizeHost(const std::string& host, | 1247 std::string CanonicalizeHost(const std::string& host, |
| 1292 url_canon::CanonHostInfo* host_info) { | 1248 url_canon::CanonHostInfo* host_info) { |
| 1293 // Try to canonicalize the host. | 1249 // Try to canonicalize the host. |
| 1294 const url_parse::Component raw_host_component( | 1250 const url_parse::Component raw_host_component( |
| 1295 0, static_cast<int>(host.length())); | 1251 0, static_cast<int>(host.length())); |
| (...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 | 2403 |
| 2448 NetworkInterface::NetworkInterface(const std::string& name, | 2404 NetworkInterface::NetworkInterface(const std::string& name, |
| 2449 const IPAddressNumber& address) | 2405 const IPAddressNumber& address) |
| 2450 : name(name), address(address) { | 2406 : name(name), address(address) { |
| 2451 } | 2407 } |
| 2452 | 2408 |
| 2453 NetworkInterface::~NetworkInterface() { | 2409 NetworkInterface::~NetworkInterface() { |
| 2454 } | 2410 } |
| 2455 | 2411 |
| 2456 } // namespace net | 2412 } // namespace net |
| OLD | NEW |