Commit 673cc761 authored by newt's avatar newt Committed by Commit bot

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

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

Cr-Commit-Position: refs/heads/master@{#296512}
parent f53a0a3b
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/values.h" #include "base/values.h"
#include "net/base/url_util.h"
namespace search_provider_logos { namespace search_provider_logos {
...@@ -19,7 +18,22 @@ const char kResponsePreamble[] = ")]}'"; ...@@ -19,7 +18,22 @@ const char kResponsePreamble[] = ")]}'";
GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url, GURL GoogleAppendFingerprintToLogoURL(const GURL& logo_url,
const std::string& fingerprint) { 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( scoped_ptr<EncodedLogo> GoogleParseLogoResponse(
......
...@@ -371,8 +371,7 @@ void LogoTrackerTest::SetServerResponseWhenFingerprint( ...@@ -371,8 +371,7 @@ void LogoTrackerTest::SetServerResponseWhenFingerprint(
const std::string& response_when_fingerprint, const std::string& response_when_fingerprint,
net::URLRequestStatus::Status request_status, net::URLRequestStatus::Status request_status,
net::HttpStatusCode response_code) { net::HttpStatusCode response_code) {
GURL url_with_fp = GURL url_with_fp = GoogleAppendFingerprintToLogoURL(logo_url_, fingerprint);
net::AppendQueryParameter(logo_url_, "async", "es_dfp:" + fingerprint);
fake_url_fetcher_factory_.SetFakeResponse( fake_url_fetcher_factory_.SetFakeResponse(
url_with_fp, response_when_fingerprint, response_code, request_status); url_with_fp, response_when_fingerprint, response_code, request_status);
} }
...@@ -384,6 +383,16 @@ void LogoTrackerTest::GetLogo() { ...@@ -384,6 +383,16 @@ void LogoTrackerTest::GetLogo() {
// Tests ----------------------------------------------------------------------- // 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) { TEST_F(LogoTrackerTest, DownloadAndCacheLogo) {
Logo logo = GetSampleLogo(logo_url_, test_clock_->Now()); Logo logo = GetSampleLogo(logo_url_, test_clock_->Now());
SetServerResponse(ServerResponse(logo)); SetServerResponse(ServerResponse(logo));
......
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