Commit b3a8a04e authored by rajendrant's avatar rajendrant Committed by Commit Bot

Remove subresource redirect origin sharding

Change-Id: Ifc8c20506e46c1be957bf551325d4bb4fd63678b
Fixed: 1142526
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2514069
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Auto-Submit: rajendrant <rajendrant@chromium.org>
Reviewed-by: default avatarRobert Ogden <robertogden@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823258}
parent 7119b431
......@@ -18,19 +18,12 @@ GURL GetSubresourceURLForURL(const GURL& original_url) {
DCHECK(original_url.is_valid());
GURL compressed_url = GetSubresourceRedirectOrigin().GetURL();
std::string origin_hash = base::ToLowerASCII(base32::Base32Encode(
crypto::SHA256HashString(
original_url.scheme() + "://" + original_url.host() + ":" +
base::NumberToString(original_url.EffectiveIntPort())),
base32::Base32EncodePolicy::OMIT_PADDING));
std::string host_str = origin_hash + "." + compressed_url.host();
std::string query_str =
"u=" + net::EscapeQueryParamValue(original_url.GetAsReferrer().spec(),
true /* use_plus */);
std::string ref_str = original_url.ref();
GURL::Replacements replacements;
replacements.SetHostStr(host_str);
replacements.SetPathStr("/i");
replacements.SetQueryStr(query_str);
if (!ref_str.empty())
......
......@@ -11,7 +11,6 @@ namespace subresource_redirect {
TEST(SubresourceRedirectURL, ProperlyChangesURL) {
EXPECT_EQ(GetSubresourceURLForURL(GURL("https://www.test.com/test.jpg")),
GURL("https://"
"jy6r5d5zc3n6juvq35nveinxzyuk4n4wndppyli5x5ycmrza36fa."
"litepages.googlezip.net/"
"i?u=https%3A%2F%2Fwww.test.com%2Ftest.jpg"));
}
......@@ -19,14 +18,13 @@ TEST(SubresourceRedirectURL, ProperlyChangesURL) {
TEST(SubresourceRedirectURL, ProperlyHandlesFragment) {
EXPECT_EQ(GetSubresourceURLForURL(GURL("https://www.test.com/test.jpg#test")),
GURL("https://"
"jy6r5d5zc3n6juvq35nveinxzyuk4n4wndppyli5x5ycmrza36fa."
"litepages.googlezip.net/"
"i?u=https%3A%2F%2Fwww.test.com%2Ftest.jpg#test"));
}
TEST(SubresourceRedirectURL, ProperlyHandlesSetPort) {
EXPECT_EQ(GetSubresourceURLForURL(GURL("https://www.test.com:4444/test.jpg")),
GURL("https://flm6clfkawcjb2bw5cnrrcdf4fkoliileuljcc23lahdet75ouqq."
GURL("https://"
"litepages.googlezip.net/i?u=https%3A%2F%2Fwww.test."
"com%3A4444%2Ftest.jpg"));
}
......@@ -35,7 +33,6 @@ TEST(SubresourceRedirectURL, ProperlyHandlesQueryParams) {
EXPECT_EQ(GetSubresourceURLForURL(
GURL("https://www.test.com/test.jpg?color=yellow")),
GURL("https://"
"jy6r5d5zc3n6juvq35nveinxzyuk4n4wndppyli5x5ycmrza36fa."
"litepages.googlezip.net/"
"i?u=https%3A%2F%2Fwww.test.com%2Ftest.jpg%3Fcolor%3Dyellow"));
}
......@@ -44,7 +41,6 @@ TEST(SubresourceRedirectURL, ProperlyHandlesMultipleQueryParams) {
EXPECT_EQ(GetSubresourceURLForURL(
GURL("https://www.test.com/test.jpg?color=yellow&name=test")),
GURL("https://"
"jy6r5d5zc3n6juvq35nveinxzyuk4n4wndppyli5x5ycmrza36fa."
"litepages.googlezip.net/"
"i?u=https%3A%2F%2Fwww.test.com%2Ftest.jpg%3Fcolor%3Dyellow%"
"26name%3Dtest"));
......@@ -54,7 +50,6 @@ TEST(SubresourceRedirectURL, ProperlyHandlesQueryParamsWithFragments) {
EXPECT_EQ(GetSubresourceURLForURL(
GURL("https://www.test.com/test.jpg?color=yellow#test")),
GURL("https://"
"jy6r5d5zc3n6juvq35nveinxzyuk4n4wndppyli5x5ycmrza36fa."
"litepages.googlezip.net/"
"i?u=https%3A%2F%2Fwww.test.com%2Ftest.jpg%3Fcolor%3Dyellow"
"#test"));
......@@ -64,7 +59,7 @@ TEST(SubresourceRedirectURL, ProperlyHandlesQueryParamsWithFragments) {
// potential to add them in the future.
TEST(SubresourceRedirectURL, ProperlyChangesHTTPURL) {
EXPECT_EQ(GetSubresourceURLForURL(GURL("http://www.test.com/test.jpg")),
GURL("https://bc6pgqmtr6nlicooao2zh77svcptncpwfolwlgbrop6gqnr6ck3q."
GURL("https://"
"litepages.googlezip.net/i?u=http%3A%2F%2Fwww.test.com%2Ftest."
"jpg"));
}
......
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