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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 212543005: Do not copy reference fragments for overridden redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add URLRequestJob::IsRedirectFragmentModificationAllowed Created 6 years, 8 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 (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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 // Even if encoding types are empty, there is a chance that we need to add 1027 // Even if encoding types are empty, there is a chance that we need to add
1028 // some decoding, as some proxies strip encoding completely. In such cases, 1028 // some decoding, as some proxies strip encoding completely. In such cases,
1029 // we may need to add (for example) SDCH filtering (when the context suggests 1029 // we may need to add (for example) SDCH filtering (when the context suggests
1030 // it is appropriate). 1030 // it is appropriate).
1031 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); 1031 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1032 1032
1033 return !encoding_types.empty() 1033 return !encoding_types.empty()
1034 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1034 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1035 } 1035 }
1036 1036
1037 bool URLRequestHttpJob::IsRedirectFragmentModificationAllowed(
1038 const GURL& location) {
1039 // Allow modification of reference fragments by default, unless
1040 // |allowed_unsafe_redirect_url_| is set and equal to the redirect URL.
1041 // When this is the case, we assume that the network delegate has set the
1042 // desired redirect URL (with or without fragment), so it must not be changed
1043 // any more.
1044 return !allowed_unsafe_redirect_url_.is_valid() ||
1045 allowed_unsafe_redirect_url_ != location;
mmenke 2014/03/31 20:45:49 The NetworkDelegate description should include thi
mmenke 2014/03/31 20:45:49 Hrm...I can't think of a reasonable name that impl
robwu 2014/04/01 16:09:33 Done.
robwu 2014/04/01 16:09:33 |redirect_url_suggested_by_network_delegate_| as m
1046 }
1047
1037 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1048 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1038 // HTTP is always safe. 1049 // HTTP is always safe.
1039 // TODO(pauljensen): Remove once crbug.com/146591 is fixed. 1050 // TODO(pauljensen): Remove once crbug.com/146591 is fixed.
1040 if (location.is_valid() && 1051 if (location.is_valid() &&
1041 (location.scheme() == "http" || location.scheme() == "https")) { 1052 (location.scheme() == "http" || location.scheme() == "https")) {
1042 return true; 1053 return true;
1043 } 1054 }
1044 // Delegates may mark an URL as safe for redirection. 1055 // Delegates may mark a URL as safe for redirection.
1045 if (allowed_unsafe_redirect_url_.is_valid()) { 1056 if (allowed_unsafe_redirect_url_.is_valid()) {
1046 GURL::Replacements replacements; 1057 return allowed_unsafe_redirect_url_ == location;
mmenke 2014/03/31 20:45:49 Think this should be: if (allowed_unsafe_redirect
robwu 2014/04/01 16:09:33 Done.
1047 replacements.ClearRef();
1048 if (allowed_unsafe_redirect_url_.ReplaceComponents(replacements) ==
1049 location.ReplaceComponents(replacements)) {
1050 return true;
1051 }
1052 } 1058 }
1053 // Query URLRequestJobFactory as to whether |location| would be safe to 1059 // Query URLRequestJobFactory as to whether |location| would be safe to
1054 // redirect to. 1060 // redirect to.
1055 return request_->context()->job_factory() && 1061 return request_->context()->job_factory() &&
1056 request_->context()->job_factory()->IsSafeRedirectTarget(location); 1062 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1057 } 1063 }
1058 1064
1059 bool URLRequestHttpJob::NeedsAuth() { 1065 bool URLRequestHttpJob::NeedsAuth() {
1060 int code = GetResponseCode(); 1066 int code = GetResponseCode();
1061 if (code == -1) 1067 if (code == -1)
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 return override_response_headers_.get() ? 1504 return override_response_headers_.get() ?
1499 override_response_headers_.get() : 1505 override_response_headers_.get() :
1500 transaction_->GetResponseInfo()->headers.get(); 1506 transaction_->GetResponseInfo()->headers.get();
1501 } 1507 }
1502 1508
1503 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1509 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1504 awaiting_callback_ = false; 1510 awaiting_callback_ = false;
1505 } 1511 }
1506 1512
1507 } // namespace net 1513 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698