Commit c88d595b authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Commit Bot

webshare: Use Resolve to get an absolute URL for the url template

Rather than concatenating we use GURL::Resolve() to get an absolute
URL based on the manifest URL and the url_template.

Change-Id: Id74041fcca6f34a898fc8c9794fc0965a1f4ccd8
Reviewed-on: https://chromium-review.googlesource.com/587704
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarMatt Giuca <mgiuca@chromium.org>
Cr-Commit-Position: refs/heads/master@{#490709}
parent 2e48351a
......@@ -191,8 +191,6 @@ void ShareServiceImpl::OnPickerClosed(const std::string& title,
return;
}
const GURL& chosen_target = result->manifest_url();
std::string url_template_filled;
if (!ReplacePlaceholders(result->url_template(), title, text, share_url,
&url_template_filled)) {
......@@ -204,12 +202,8 @@ void ShareServiceImpl::OnPickerClosed(const std::string& title,
}
// The template is relative to the manifest URL (minus the filename).
// Concatenate to make an absolute URL.
const std::string& chosen_target_spec = chosen_target.spec();
base::StringPiece url_base(
chosen_target_spec.data(),
chosen_target_spec.size() - chosen_target.ExtractFileName().size());
const GURL target(url_base.as_string() + url_template_filled);
// Resolve it based on the manifest URL to make an absolute URL.
const GURL target = result->manifest_url().Resolve(url_template_filled);
// User should not be able to cause an invalid target URL. Possibilities are:
// - The base URL: can't be invalid since it's derived from the manifest URL.
// - The template: can only be invalid if it contains a NUL character or
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment