OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_log_util.h" | 5 #include "net/http/http_log_util.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "net/http/http_auth_challenge_tokenizer.h" | 9 #include "net/http/http_auth_challenge_tokenizer.h" |
10 #include "net/http/http_util.h" | 10 #include "net/http/http_util.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { | 16 bool ShouldRedactChallenge(HttpAuthChallengeTokenizer* challenge) { |
17 // Ignore lines with commas, as they may contain lists of schemes, and | 17 // Ignore lines with commas, as they may contain lists of schemes, and |
18 // the information we want to hide is Base64 encoded, so has no commas. | 18 // the information we want to hide is Base64 encoded, so has no commas. |
19 if (challenge->challenge_text().find(',') != std::string::npos) | 19 if (challenge->challenge_text().find(',') != std::string::npos) |
20 return false; | 20 return false; |
21 | 21 |
22 std::string scheme = base::StringToLowerASCII(challenge->scheme()); | 22 std::string scheme = base::ToLowerASCII(challenge->scheme()); |
23 // Invalid input. | 23 // Invalid input. |
24 if (scheme.empty()) | 24 if (scheme.empty()) |
25 return false; | 25 return false; |
26 | 26 |
27 // Ignore Basic and Digest authentication challenges, as they contain | 27 // Ignore Basic and Digest authentication challenges, as they contain |
28 // public information. | 28 // public information. |
29 if (scheme == "basic" || scheme == "digest") | 29 if (scheme == "basic" || scheme == "digest") |
30 return false; | 30 return false; |
31 | 31 |
32 return true; | 32 return true; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (redact_begin == redact_end) | 67 if (redact_begin == redact_end) |
68 return value; | 68 return value; |
69 | 69 |
70 return std::string(value.begin(), redact_begin) + | 70 return std::string(value.begin(), redact_begin) + |
71 base::StringPrintf("[%ld bytes were stripped]", | 71 base::StringPrintf("[%ld bytes were stripped]", |
72 static_cast<long>(redact_end - redact_begin)) + | 72 static_cast<long>(redact_end - redact_begin)) + |
73 std::string(redact_end, value.end()); | 73 std::string(redact_end, value.end()); |
74 } | 74 } |
75 | 75 |
76 } // namespace net | 76 } // namespace net |
OLD | NEW |