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

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 2452443002: Drop navigations to NavigationEntry with invalid virtual URLs. (Closed)
Patch Set: Fix comment. Created 4 years, 1 month 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 | « chrome/browser/chrome_navigation_browsertest.cc ('k') | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && 295 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL &&
296 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { 296 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) {
297 // We may have been redirected when navigating to the current URL. 297 // We may have been redirected when navigating to the current URL.
298 // Use the URL the user originally intended to visit, if it's valid and if a 298 // Use the URL the user originally intended to visit, if it's valid and if a
299 // POST wasn't involved; the latter case avoids issues with sending data to 299 // POST wasn't involved; the latter case avoids issues with sending data to
300 // the wrong page. 300 // the wrong page.
301 dest_url = entry.GetOriginalRequestURL(); 301 dest_url = entry.GetOriginalRequestURL();
302 dest_referrer = Referrer(); 302 dest_referrer = Referrer();
303 } 303 }
304 304
305 // Don't attempt to navigate if the virtual URL is non-empty and invalid.
306 if (frame_tree_node->IsMainFrame()) {
307 const GURL& virtual_url = entry.GetVirtualURL();
308 if (!virtual_url.is_valid() && !virtual_url.is_empty()) {
309 LOG(WARNING) << "Refusing to load for invalid virtual URL: "
310 << virtual_url.possibly_invalid_spec();
311 return false;
312 }
313 }
314
305 // Don't attempt to navigate to non-empty invalid URLs. 315 // Don't attempt to navigate to non-empty invalid URLs.
306 if (!dest_url.is_valid() && !dest_url.is_empty()) { 316 if (!dest_url.is_valid() && !dest_url.is_empty()) {
307 LOG(WARNING) << "Refusing to load invalid URL: " 317 LOG(WARNING) << "Refusing to load invalid URL: "
308 << dest_url.possibly_invalid_spec(); 318 << dest_url.possibly_invalid_spec();
309 return false; 319 return false;
310 } 320 }
311 321
312 // The renderer will reject IPC messages with URLs longer than 322 // The renderer will reject IPC messages with URLs longer than
313 // this limit, so don't attempt to navigate with a longer URL. 323 // this limit, so don't attempt to navigate with a longer URL.
314 if (dest_url.spec().size() > url::kMaxURLChars) { 324 if (dest_url.spec().size() > url::kMaxURLChars) {
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 if (navigation_handle) 1257 if (navigation_handle)
1248 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1258 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1249 1259
1250 controller_->SetPendingEntry(std::move(entry)); 1260 controller_->SetPendingEntry(std::move(entry));
1251 if (delegate_) 1261 if (delegate_)
1252 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1262 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1253 } 1263 }
1254 } 1264 }
1255 1265
1256 } // namespace content 1266 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_navigation_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698