Commit eaf576d2 authored by Frédéric Wang's avatar Frédéric Wang Committed by Commit Bot

percent-encode U+0020 SPACE when using a protocol handler

Currently, URLs calculated by protocol handlers escape spaces as "+".
This CL changes this to use "%20" instead, aligning with Firefox and
the specification.

For details, read the following links:
https://chromestatus.com/feature/5678518908223488
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/osabCTBhDSs
https://bugs.chromium.org/p/chromium/issues/detail?id=795919
https://html.spec.whatwg.org/multipage/system-state.html#custom-handlers
https://github.com/whatwg/html/issues/3377

Bug: 1110842
Change-Id: I31e2250c56d3c4654d5a8655ead953af33b5fb5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324126Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Frédéric Wang <fwang@igalia.com>
Cr-Commit-Position: refs/heads/master@{#799541}
parent b92e226e
...@@ -977,9 +977,8 @@ TEST_F(ProtocolHandlerRegistryTest, TestURIPercentEncoding) { ...@@ -977,9 +977,8 @@ TEST_F(ProtocolHandlerRegistryTest, TestURIPercentEncoding) {
// Space character. // Space character.
translated_url = ph.TranslateUrl(GURL("web+custom://custom handler")); translated_url = ph.TranslateUrl(GURL("web+custom://custom handler"));
// TODO(mgiuca): Check whether this(' ') should be encoded as '%20'.
ASSERT_EQ(translated_url, ASSERT_EQ(translated_url,
GURL("https://test.com/url=web%2Bcustom%3A%2F%2Fcustom+handler")); GURL("https://test.com/url=web%2Bcustom%3A%2F%2Fcustom%20handler"));
// Query parameters. // Query parameters.
translated_url = ph.TranslateUrl(GURL("web+custom://custom?foo=bar&bar=baz")); translated_url = ph.TranslateUrl(GURL("web+custom://custom?foo=bar&bar=baz"));
......
...@@ -98,7 +98,7 @@ GURL ProtocolHandler::TranslateUrl(const GURL& url) const { ...@@ -98,7 +98,7 @@ GURL ProtocolHandler::TranslateUrl(const GURL& url) const {
std::string translatedUrlSpec(url_.spec()); std::string translatedUrlSpec(url_.spec());
base::ReplaceFirstSubstringAfterOffset( base::ReplaceFirstSubstringAfterOffset(
&translatedUrlSpec, 0, "%s", &translatedUrlSpec, 0, "%s",
net::EscapeQueryParamValue(url.spec(), true)); net::EscapeQueryParamValue(url.spec(), false));
return GURL(translatedUrlSpec); return GURL(translatedUrlSpec);
} }
......
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