Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5904)

Unified Diff: chrome/common/chrome_content_client.cc

Issue 491123004: Make sure that HttpRequestHeaders contains valid key-value pairs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: edit comment Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/chrome_content_client.cc
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index fde26efe605f2a4fc36338fbdbb439ee46eb9f70..6bff669396d91b9b6938395fd64d466ed65152ab 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -34,6 +34,7 @@
#include "content/public/common/user_agent.h"
#include "extensions/common/constants.h"
#include "gpu/config/gpu_info.h"
+#include "net/http/http_util.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
@@ -418,8 +419,12 @@ std::string GetProduct() {
std::string GetUserAgent() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kUserAgent))
- return command_line->GetSwitchValueASCII(switches::kUserAgent);
+ if (command_line->HasSwitch(switches::kUserAgent)) {
+ std::string ua = command_line->GetSwitchValueASCII(switches::kUserAgent);
+ if (net::HttpUtil::IsValidHeaderValue(ua))
+ return ua;
+ LOG(WARNING) << "Ignored invalid value for flag --" << switches::kUserAgent;
+ }
std::string product = GetProduct();
#if defined(OS_ANDROID)
« no previous file with comments | « chrome/browser/extensions/api/web_request/web_request_api_helpers.cc ('k') | net/http/http_request_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698