Index: net/http/http_log_util.cc |
diff --git a/net/http/http_log_util.cc b/net/http/http_log_util.cc |
index ab6ebda74aca0be5b39b9bfc046e91943e20c4bd..570232fc3e75be5e049372094825c68b7de51bce 100644 |
--- a/net/http/http_log_util.cc |
+++ b/net/http/http_log_util.cc |
@@ -7,6 +7,7 @@ |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
#include "net/http/http_auth_challenge_tokenizer.h" |
+#include "net/http/http_util.h" |
namespace net { |
@@ -33,39 +34,57 @@ bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { |
} // namespace |
+#if defined(SPDY_PROXY_AUTH_ORIGIN) |
+void ElideChromeProxyDirective(const std::string& header_value, |
+ const std::string& directive, |
+ std::string::const_iterator* redact_begin, |
+ std::string::const_iterator* redact_end) { |
+ HttpUtil::ValuesIterator it(header_value.begin(), header_value.end(), ','); |
+ while (it.GetNext()) { |
+ if (LowerCaseEqualsASCII(it.value_begin(), |
+ it.value_begin() + directive.size(), |
+ directive.c_str())) { |
+ *redact_begin = it.value_begin(); |
+ *redact_end = it.value_end(); |
+ return; |
+ } |
+ } |
+} |
+#endif |
+ |
std::string ElideHeaderValueForNetLog(NetLog::LogLevel log_level, |
const std::string& header, |
const std::string& value) { |
+ std::string::const_iterator redact_begin = value.begin(); |
+ std::string::const_iterator redact_end = value.begin(); |
#if defined(SPDY_PROXY_AUTH_ORIGIN) |
- if (!base::strcasecmp(header.c_str(), "proxy-authorization") || |
- !base::strcasecmp(header.c_str(), "proxy-authenticate")) { |
- return "[elided]"; |
+ if (!base::strcasecmp(header.c_str(), "chrome-proxy")) { |
+ ElideChromeProxyDirective(value, "sid=", &redact_begin, &redact_end); |
} |
#endif |
- if (log_level < NetLog::LOG_STRIP_PRIVATE_DATA) |
- return value; |
- |
- // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in |
- // chrome/browser/resources/net_internals/log_view_painter.js. |
- |
- std::string::const_iterator redact_begin = value.begin(); |
- std::string::const_iterator redact_end = value.begin(); |
- if (!base::strcasecmp(header.c_str(), "set-cookie") || |
- !base::strcasecmp(header.c_str(), "set-cookie2") || |
- !base::strcasecmp(header.c_str(), "cookie") || |
- !base::strcasecmp(header.c_str(), "authorization") || |
- !base::strcasecmp(header.c_str(), "proxy-authorization")) { |
- redact_begin = value.begin(); |
- redact_end = value.end(); |
- } else if (!base::strcasecmp(header.c_str(), "www-authenticate") || |
- !base::strcasecmp(header.c_str(), "proxy-authenticate")) { |
- // Look for authentication information from data received from the server in |
- // multi-round Negotiate authentication. |
- HttpAuthChallengeTokenizer challenge(value.begin(), value.end()); |
- if (ShouldRedactChallenge(&challenge)) { |
- redact_begin = challenge.params_begin(); |
- redact_end = challenge.params_end(); |
+ if (redact_begin == redact_end && |
+ log_level >= NetLog::LOG_STRIP_PRIVATE_DATA) { |
+ |
+ // Note: this logic should be kept in sync with stripCookiesAndLoginInfo in |
+ // chrome/browser/resources/net_internals/log_view_painter.js. |
+ |
+ if (!base::strcasecmp(header.c_str(), "set-cookie") || |
+ !base::strcasecmp(header.c_str(), "set-cookie2") || |
+ !base::strcasecmp(header.c_str(), "cookie") || |
+ !base::strcasecmp(header.c_str(), "authorization") || |
+ !base::strcasecmp(header.c_str(), "proxy-authorization")) { |
+ redact_begin = value.begin(); |
+ redact_end = value.end(); |
+ } else if (!base::strcasecmp(header.c_str(), "www-authenticate") || |
+ !base::strcasecmp(header.c_str(), "proxy-authenticate")) { |
+ // Look for authentication information from data received from the server |
+ // in multi-round Negotiate authentication. |
+ HttpAuthChallengeTokenizer challenge(value.begin(), value.end()); |
+ if (ShouldRedactChallenge(&challenge)) { |
+ redact_begin = challenge.params_begin(); |
+ redact_end = challenge.params_end(); |
+ } |
} |
} |