| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/safe_browsing_util.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return true; | 265 return true; |
| 266 } | 266 } |
| 267 | 267 |
| 268 std::string Unescape(const std::string& url) { | 268 std::string Unescape(const std::string& url) { |
| 269 std::string unescaped_str(url); | 269 std::string unescaped_str(url); |
| 270 std::string old_unescaped_str; | 270 std::string old_unescaped_str; |
| 271 const int kMaxLoopIterations = 1024; | 271 const int kMaxLoopIterations = 1024; |
| 272 int loop_var = 0; | 272 int loop_var = 0; |
| 273 do { | 273 do { |
| 274 old_unescaped_str = unescaped_str; | 274 old_unescaped_str = unescaped_str; |
| 275 unescaped_str = net::UnescapeURLComponent(old_unescaped_str, | 275 unescaped_str = net::UnescapeURLComponent( |
| 276 net::UnescapeRule::CONTROL_CHARS | net::UnescapeRule::SPACES | | 276 old_unescaped_str, net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS | |
| 277 net::UnescapeRule::URL_SPECIAL_CHARS); | 277 net::UnescapeRule::SPACES | |
| 278 net::UnescapeRule::URL_SPECIAL_CHARS); |
| 278 } while (unescaped_str != old_unescaped_str && ++loop_var <= | 279 } while (unescaped_str != old_unescaped_str && ++loop_var <= |
| 279 kMaxLoopIterations); | 280 kMaxLoopIterations); |
| 280 | 281 |
| 281 return unescaped_str; | 282 return unescaped_str; |
| 282 } | 283 } |
| 283 | 284 |
| 284 std::string Escape(const std::string& url) { | 285 std::string Escape(const std::string& url) { |
| 285 std::string escaped_str; | 286 std::string escaped_str; |
| 286 const char* kHexString = "0123456789ABCDEF"; | 287 const char* kHexString = "0123456789ABCDEF"; |
| 287 for (size_t i = 0; i < url.length(); i++) { | 288 for (size_t i = 0; i < url.length(); i++) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 memcpy(hash_out.full_hash, hash_in.data(), crypto::kSHA256Length); | 519 memcpy(hash_out.full_hash, hash_in.data(), crypto::kSHA256Length); |
| 519 return hash_out; | 520 return hash_out; |
| 520 } | 521 } |
| 521 | 522 |
| 522 std::string SBFullHashToString(const SBFullHash& hash) { | 523 std::string SBFullHashToString(const SBFullHash& hash) { |
| 523 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); | 524 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); |
| 524 return std::string(hash.full_hash, sizeof(hash.full_hash)); | 525 return std::string(hash.full_hash, sizeof(hash.full_hash)); |
| 525 } | 526 } |
| 526 | 527 |
| 527 } // namespace safe_browsing_util | 528 } // namespace safe_browsing_util |
| OLD | NEW |