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

Side by Side Diff: chromeos/network/onc/onc_utils.cc

Issue 2608803002: ONC: Fix handling of invalid proxy scheme. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chromeos/network/onc/onc_utils.h" 5 #include "chromeos/network/onc/onc_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 924
925 if (type == ::onc::proxy::kDirect) { 925 if (type == ::onc::proxy::kDirect) {
926 proxy_dict.reset(ProxyConfigDictionary::CreateDirect()); 926 proxy_dict.reset(ProxyConfigDictionary::CreateDirect());
927 } else if (type == ::onc::proxy::kWPAD) { 927 } else if (type == ::onc::proxy::kWPAD) {
928 proxy_dict.reset(ProxyConfigDictionary::CreateAutoDetect()); 928 proxy_dict.reset(ProxyConfigDictionary::CreateAutoDetect());
929 } else if (type == ::onc::proxy::kPAC) { 929 } else if (type == ::onc::proxy::kPAC) {
930 std::string pac_url; 930 std::string pac_url;
931 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC, 931 onc_proxy_settings.GetStringWithoutPathExpansion(::onc::proxy::kPAC,
932 &pac_url); 932 &pac_url);
933 GURL url(pac_url); 933 GURL url(pac_url);
934 DCHECK(url.is_valid()) << "Invalid URL in ProxySettings.PAC"; 934 if (!url.is_valid()) {
935 // Assume the scheme is missing, use http.
936 url = GURL(std::string(url::kHttpScheme) + url::kStandardSchemeSeparator +
emaxx 2016/12/29 22:05:36 This logic looks a bit crude to me. Could we use h
stevenjb 2016/12/29 22:44:18 Ah, I was looking for something like that but didn
937 pac_url);
938 if (!url.is_valid()) {
939 LOG(WARNING) << "Invalid URL in ProxySettings.PAC: " << pac_url;
940 url = GURL();
941 }
942 }
935 proxy_dict.reset(ProxyConfigDictionary::CreatePacScript(url.spec(), false)); 943 proxy_dict.reset(ProxyConfigDictionary::CreatePacScript(url.spec(), false));
936 } else if (type == ::onc::proxy::kManual) { 944 } else if (type == ::onc::proxy::kManual) {
937 const base::DictionaryValue* manual_dict = nullptr; 945 const base::DictionaryValue* manual_dict = nullptr;
938 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual, 946 onc_proxy_settings.GetDictionaryWithoutPathExpansion(::onc::proxy::kManual,
939 &manual_dict); 947 &manual_dict);
940 std::string manual_spec; 948 std::string manual_spec;
941 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec); 949 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kFtp, &manual_spec);
942 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec); 950 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kHttp, &manual_spec);
943 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks, 951 AppendProxyServerForScheme(*manual_dict, ::onc::proxy::kSocks,
944 &manual_spec); 952 &manual_spec);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 const PrefService* local_state_prefs, 1326 const PrefService* local_state_prefs,
1319 const NetworkState& network) { 1327 const NetworkState& network) {
1320 ::onc::ONCSource ignored_onc_source; 1328 ::onc::ONCSource ignored_onc_source;
1321 const base::DictionaryValue* policy = onc::GetPolicyForNetwork( 1329 const base::DictionaryValue* policy = onc::GetPolicyForNetwork(
1322 profile_prefs, local_state_prefs, network, &ignored_onc_source); 1330 profile_prefs, local_state_prefs, network, &ignored_onc_source);
1323 return policy != NULL; 1331 return policy != NULL;
1324 } 1332 }
1325 1333
1326 } // namespace onc 1334 } // namespace onc
1327 } // namespace chromeos 1335 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698