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

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

Issue 2459913003: Drop navigations to NavigationEntry with invalid virtual URLs. (Closed)
Patch Set: 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && 285 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL &&
286 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { 286 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) {
287 // We may have been redirected when navigating to the current URL. 287 // We may have been redirected when navigating to the current URL.
288 // Use the URL the user originally intended to visit, if it's valid and if a 288 // Use the URL the user originally intended to visit, if it's valid and if a
289 // POST wasn't involved; the latter case avoids issues with sending data to 289 // POST wasn't involved; the latter case avoids issues with sending data to
290 // the wrong page. 290 // the wrong page.
291 dest_url = entry.GetOriginalRequestURL(); 291 dest_url = entry.GetOriginalRequestURL();
292 dest_referrer = Referrer(); 292 dest_referrer = Referrer();
293 } 293 }
294 294
295 // Don't attempt to navigate if the virtual URL is non-empty and invalid.
296 if (frame_tree_node->IsMainFrame()) {
297 const GURL& virtual_url = entry.GetVirtualURL();
298 if (!virtual_url.is_valid() && !virtual_url.is_empty()) {
299 LOG(WARNING) << "Refusing to load for invalid virtual URL: "
300 << virtual_url.possibly_invalid_spec();
301 return false;
302 }
303 }
304
295 // Don't attempt to navigate to non-empty invalid URLs. 305 // Don't attempt to navigate to non-empty invalid URLs.
296 if (!dest_url.is_valid() && !dest_url.is_empty()) { 306 if (!dest_url.is_valid() && !dest_url.is_empty()) {
297 LOG(WARNING) << "Refusing to load invalid URL: " 307 LOG(WARNING) << "Refusing to load invalid URL: "
298 << dest_url.possibly_invalid_spec(); 308 << dest_url.possibly_invalid_spec();
299 return false; 309 return false;
300 } 310 }
301 311
302 // The renderer will reject IPC messages with URLs longer than 312 // The renderer will reject IPC messages with URLs longer than
303 // this limit, so don't attempt to navigate with a longer URL. 313 // this limit, so don't attempt to navigate with a longer URL.
304 if (dest_url.spec().size() > url::kMaxURLChars) { 314 if (dest_url.spec().size() > url::kMaxURLChars) {
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 if (navigation_handle) 1244 if (navigation_handle)
1235 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); 1245 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID());
1236 1246
1237 controller_->SetPendingEntry(std::move(entry)); 1247 controller_->SetPendingEntry(std::move(entry));
1238 if (delegate_) 1248 if (delegate_)
1239 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); 1249 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
1240 } 1250 }
1241 } 1251 }
1242 1252
1243 } // namespace content 1253 } // 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