Chromium Code Reviews| 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 "components/auto_login_parser/auto_login_parser.h" | 5 #include "components/auto_login_parser/auto_login_parser.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 base::StringPairs pairs; | 47 base::StringPairs pairs; |
| 48 if (!base::SplitStringIntoKeyValuePairs(header, '=', '&', &pairs)) | 48 if (!base::SplitStringIntoKeyValuePairs(header, '=', '&', &pairs)) |
| 49 return false; | 49 return false; |
| 50 | 50 |
| 51 // Parse the information from the |header| string. | 51 // Parse the information from the |header| string. |
| 52 HeaderData local_params; | 52 HeaderData local_params; |
| 53 for (base::StringPairs::const_iterator it = pairs.begin(); it != pairs.end(); | 53 for (base::StringPairs::const_iterator it = pairs.begin(); it != pairs.end(); |
| 54 ++it) { | 54 ++it) { |
| 55 const std::string& key = it->first; | 55 const std::string& key = it->first; |
| 56 const std::string& value = it->second; | 56 const std::string& value = it->second; |
| 57 std::string unescaped_value( | 57 std::string unescaped_value(net::UnescapeURLComponent( |
| 58 net::UnescapeURLComponent(value, net::UnescapeRule::URL_SPECIAL_CHARS)); | 58 value, |
| 59 net::UnescapeRule::PATH_SEPARATORS | | |
| 60 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS)); | |
|
mmenke
2016/03/16 21:30:00
Looks safe - not used as a path.
| |
| 59 if (key == "realm") { | 61 if (key == "realm") { |
| 60 if (!MatchRealm(unescaped_value, realm_restriction)) | 62 if (!MatchRealm(unescaped_value, realm_restriction)) |
| 61 return false; | 63 return false; |
| 62 local_params.realm = unescaped_value; | 64 local_params.realm = unescaped_value; |
| 63 } else if (key == "account") { | 65 } else if (key == "account") { |
| 64 local_params.account = unescaped_value; | 66 local_params.account = unescaped_value; |
| 65 } else if (key == "args") { | 67 } else if (key == "args") { |
| 66 local_params.args = unescaped_value; | 68 local_params.args = unescaped_value; |
| 67 } | 69 } |
| 68 } | 70 } |
| 69 if (local_params.realm.empty() || local_params.args.empty()) | 71 if (local_params.realm.empty() || local_params.args.empty()) |
| 70 return false; | 72 return false; |
| 71 | 73 |
| 72 *header_data = local_params; | 74 *header_data = local_params; |
| 73 return true; | 75 return true; |
| 74 } | 76 } |
| 75 | 77 |
| 76 bool ParserHeaderInResponse(net::URLRequest* request, | 78 bool ParserHeaderInResponse(net::URLRequest* request, |
| 77 RealmRestriction realm_restriction, | 79 RealmRestriction realm_restriction, |
| 78 HeaderData* header_data) { | 80 HeaderData* header_data) { |
| 79 std::string header_string; | 81 std::string header_string; |
| 80 request->GetResponseHeaderByName(kHeaderName, &header_string); | 82 request->GetResponseHeaderByName(kHeaderName, &header_string); |
| 81 return ParseHeader(header_string, realm_restriction, header_data); | 83 return ParseHeader(header_string, realm_restriction, header_data); |
| 82 } | 84 } |
| 83 | 85 |
| 84 } // namespace auto_login_parser | 86 } // namespace auto_login_parser |
| OLD | NEW |