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

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

Issue 2528813002: Fix Self-Referencing OOPIF Infinite Loop (Closed)
Patch Set: refactor allowedToLoadFrame conditional Created 3 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/debug/dump_without_crashing.h" 9 #include "base/debug/dump_without_crashing.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 Referrer(redirect_chain_[0], sanitized_referrer.policy); 502 Referrer(redirect_chain_[0], sanitized_referrer.policy);
503 } else { 503 } else {
504 sanitized_referrer_ = sanitized_referrer; 504 sanitized_referrer_ = sanitized_referrer;
505 } 505 }
506 is_external_protocol_ = is_external_protocol; 506 is_external_protocol_ = is_external_protocol;
507 request_context_type_ = request_context_type; 507 request_context_type_ = request_context_type;
508 mixed_content_context_type_ = mixed_content_context_type; 508 mixed_content_context_type_ = mixed_content_context_type;
509 state_ = WILL_SEND_REQUEST; 509 state_ = WILL_SEND_REQUEST;
510 complete_callback_ = callback; 510 complete_callback_ = callback;
511 511
512 if (IsSelfReferentialURL()) {
513 state_ = CANCELING;
514 RunCompleteCallback(NavigationThrottle::CANCEL);
515 return;
516 }
517
512 RegisterNavigationThrottles(); 518 RegisterNavigationThrottles();
513 519
514 if (IsBrowserSideNavigationEnabled()) 520 if (IsBrowserSideNavigationEnabled())
515 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); 521 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this);
516 522
517 // Notify each throttle of the request. 523 // Notify each throttle of the request.
518 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); 524 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest();
519 525
520 // If the navigation is not deferred, run the callback. 526 // If the navigation is not deferred, run the callback.
521 if (result != NavigationThrottle::DEFER) 527 if (result != NavigationThrottle::DEFER)
(...skipping 22 matching lines...) Expand all
544 response_headers_ = response_headers; 550 response_headers_ = response_headers;
545 connection_info_ = connection_info; 551 connection_info_ = connection_info;
546 was_redirected_ = true; 552 was_redirected_ = true;
547 redirect_chain_.push_back(new_url); 553 redirect_chain_.push_back(new_url);
548 if (new_method != "POST") 554 if (new_method != "POST")
549 resource_request_body_ = nullptr; 555 resource_request_body_ = nullptr;
550 556
551 state_ = WILL_REDIRECT_REQUEST; 557 state_ = WILL_REDIRECT_REQUEST;
552 complete_callback_ = callback; 558 complete_callback_ = callback;
553 559
560 if (IsSelfReferentialURL()) {
561 state_ = CANCELING;
562 RunCompleteCallback(NavigationThrottle::CANCEL);
563 return;
564 }
565
554 // Notify each throttle of the request. 566 // Notify each throttle of the request.
555 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); 567 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest();
556 568
557 // If the navigation is not deferred, run the callback. 569 // If the navigation is not deferred, run the callback.
558 if (result != NavigationThrottle::DEFER) 570 if (result != NavigationThrottle::DEFER)
559 RunCompleteCallback(result); 571 RunCompleteCallback(result);
560 } 572 }
561 573
562 void NavigationHandleImpl::WillProcessResponse( 574 void NavigationHandleImpl::WillProcessResponse(
563 RenderFrameHostImpl* render_frame_host, 575 RenderFrameHostImpl* render_frame_host,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = 894 std::unique_ptr<content::NavigationThrottle> ancestor_throttle =
883 content::AncestorThrottle::MaybeCreateThrottleFor(this); 895 content::AncestorThrottle::MaybeCreateThrottleFor(this);
884 if (ancestor_throttle) 896 if (ancestor_throttle)
885 throttles_.push_back(std::move(ancestor_throttle)); 897 throttles_.push_back(std::move(ancestor_throttle));
886 898
887 throttles_.insert(throttles_.begin(), 899 throttles_.insert(throttles_.begin(),
888 std::make_move_iterator(throttles_to_register.begin()), 900 std::make_move_iterator(throttles_to_register.begin()),
889 std::make_move_iterator(throttles_to_register.end())); 901 std::make_move_iterator(throttles_to_register.end()));
890 } 902 }
891 903
904 bool NavigationHandleImpl::IsSelfReferentialURL() {
905 // about: URLs should be exempted since they are reserved for other purposes
906 // and cannot be the source of infinite recursion. See
907 // https://crbug.com/341858 .
908 if (url_.SchemeIs("about"))
909 return false;
910
911 // Browser-triggered navigations should be exempted.
912 if (!is_renderer_initiated_)
913 return false;
914
915 // We allow one level of self-reference because some sites depend on that,
916 // but we don't allow more than one.
917 bool found_self_reference = false;
918 for (const FrameTreeNode* node = frame_tree_node_->parent(); node;
919 node = node->parent()) {
920 if (node->current_url().EqualsIgnoringRef(url_)) {
921 if (found_self_reference)
922 return true;
923 found_self_reference = true;
924 }
925 }
926 return false;
927 }
928
892 } // namespace content 929 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698