0

Revert of Revert of Fix doodle verification URL. (patchset id:1 of https://codereview.chromium.org/599243002/)

Reason for revert:
The original revert was a mistake. Relanding this with no changed.

Original issue's description:
> Revert of Fix doodle verification URL. (patchset  id:40001 of https://codereview.chromium.org/587943003/)
>
> Reason for revert:
> Caused test failure:
> http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Tests%20%283%29/builds/7944
>
> Original issue's description:
> > Fix doodle verification URL.
> >
> > When verifying that the cached doodle is still valid, we load the doodle
> > URL and append the query param "async=es_dfp:<fingerprint>". Previously,
> > the ":" was being escape to "%3A", causing the server to respond with a
> > 400 error. This mollifies the server by keeping the colon unescaped.
> >
> > BUG=413845
> >
> > Committed: https://crrev.com/673cc76103079eaada968c537c6605dbaf8d909c
> > Cr-Commit-Position: refs/heads/master@{#296512}
>
> TBR=justincohen@chromium.org,rsleevi@chromium.org,mmenke@chromium.org,newt@chromium.org
> NOTREECHECKS=true
> NOTRY=true
> BUG=413845
>
> Committed: https://crrev.com/6101b6321585a402ffc7c45dbb4fc61bc36f0051
> Cr-Commit-Position: refs/heads/master@{#296546}

TBR=justincohen@chromium.org,rsleevi@chromium.org,mmenke@chromium.org,groby@chromium.org,jiayl@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=413845

Review URL: https://codereview.chromium.org/606443004

Cr-Commit-Position: refs/heads/master@{#296556}
This commit is contained in:
newt
2014-09-24 16:21:15 -07:00
committed by Commit bot
parent ba5d32190d
commit ac852f9a91
2 changed files with 27 additions and 4 deletions
components/search_provider_logos

@ -9,7 +9,6 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "net/base/url_util.h"
namespace search_provider_logos {
@ -19,7 +18,22 @@ const char kResponsePreamble[] = ")]}'";
GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url,
const std::string& fingerprint) {
return net::AppendQueryParameter(logo_url, "async", "es_dfp:" + fingerprint);
// Note: we can't just use net::AppendQueryParameter() because it escapes
// ":" to "%3A", but the server requires the colon not to be escaped.
// See: http://crbug.com/413845
// TODO(newt): Switch to using net::AppendQueryParameter once it no longer
// escapes ":"
std::string query(logo_url.query());
if (!query.empty())
query += "&";
query += "async=es_dfp:";
query += fingerprint;
GURL::Replacements replacements;
replacements.SetQueryStr(query);
return logo_url.ReplaceComponents(replacements);
}
scoped_ptr<EncodedLogo> GoogleParseLogoResponse(

@ -371,8 +371,7 @@ void LogoTrackerTest::SetServerResponseWhenFingerprint(
const std::string& response_when_fingerprint,
net::URLRequestStatus::Status request_status,
net::HttpStatusCode response_code) {
GURL url_with_fp =
net::AppendQueryParameter(logo_url_, "async", "es_dfp:" + fingerprint);
GURL url_with_fp = GoogleAppendFingerprintToLogoURL(logo_url_, fingerprint);
fake_url_fetcher_factory_.SetFakeResponse(
url_with_fp, response_when_fingerprint, response_code, request_status);
}
@ -384,6 +383,16 @@ void LogoTrackerTest::GetLogo() {
// Tests -----------------------------------------------------------------------
TEST_F(LogoTrackerTest, FingerprintURLHasColon) {
GURL url_with_fp = GoogleAppendFingerprintToLogoURL(
GURL("http://logourl.com/path"), "abc123");
EXPECT_EQ("http://logourl.com/path?async=es_dfp:abc123", url_with_fp.spec());
url_with_fp = GoogleAppendFingerprintToLogoURL(
GURL("http://logourl.com/?a=b"), "cafe0");
EXPECT_EQ("http://logourl.com/?a=b&async=es_dfp:cafe0", url_with_fp.spec());
}
TEST_F(LogoTrackerTest, DownloadAndCacheLogo) {
Logo logo = GetSampleLogo(logo_url_, test_clock_->Now());
SetServerResponse(ServerResponse(logo));