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

Unified Diff: content/browser/webui/url_data_manager_backend.cc

Issue 1217503012: Avoid cross-origin iframe issues when loading PDF in print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/webui/url_data_manager_backend.cc
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc
index ba1f5d4646e05e7298698d9320121da7aa85489b..1cab8ae6aff41c69f79d678ab6668cafacc787ea 100644
--- a/content/browser/webui/url_data_manager_backend.cc
+++ b/content/browser/webui/url_data_manager_backend.cc
@@ -82,14 +82,18 @@ bool CheckURLIsValid(const GURL& url) {
// Parse |url| to get the path which will be used to resolve the request. The
// path is the remaining portion after the scheme and hostname.
-void URLToRequestPath(const GURL& url, std::string* path) {
+std::string URLToRequestPath(const GURL& url) {
Charlie Reis 2015/07/16 19:25:03 Why can't we just use GURL::path()? This seems to
raymes 2015/07/17 01:58:29 I don't know the answer to that, I didn't write th
Charlie Reis 2015/07/17 23:45:22 Wow, this goes back to the initial commit: https:/
raymes 2015/07/20 06:46:22 I no longer change this file in the latest patchse
const std::string& spec = url.possibly_invalid_spec();
const url::Parsed& parsed = url.parsed_for_possibly_invalid_spec();
// + 1 to skip the slash at the beginning of the path.
int offset = parsed.CountCharactersBefore(url::Parsed::PATH, false) + 1;
+ std::string path;
if (offset < static_cast<int>(spec.size()))
- path->assign(spec.substr(offset));
+ path = spec.substr(offset);
+
+ // Remove the query string if there is one.
+ return path.substr(0, path.find_last_of('?'));
}
// Returns a value of 'Origin:' header for the |request| if the header is set.
@@ -585,8 +589,7 @@ bool URLDataManagerBackend::StartRequest(const net::URLRequest* request,
if (!source->source()->ShouldServiceRequest(request))
return false;
- std::string path;
- URLToRequestPath(request->url(), &path);
+ std::string path = URLToRequestPath(request->url());
source->source()->WillServiceRequest(request, &path);
// Save this request so we know where to send the data.

Powered by Google App Engine
This is Rietveld 408576698