OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 | 220 |
221 std::string Unescape(const std::string& url) { | 221 std::string Unescape(const std::string& url) { |
222 std::string unescaped_str(url); | 222 std::string unescaped_str(url); |
223 std::string old_unescaped_str; | 223 std::string old_unescaped_str; |
224 const int kMaxLoopIterations = 1024; | 224 const int kMaxLoopIterations = 1024; |
225 int loop_var = 0; | 225 int loop_var = 0; |
226 do { | 226 do { |
227 old_unescaped_str = unescaped_str; | 227 old_unescaped_str = unescaped_str; |
228 unescaped_str = net::UnescapeURLComponent(old_unescaped_str, | 228 unescaped_str = net::UnescapeURLComponent(old_unescaped_str, |
229 UnescapeRule::CONTROL_CHARS | UnescapeRule::SPACES | | 229 net::UnescapeRule::CONTROL_CHARS | net::UnescapeRule::SPACES | |
230 UnescapeRule::URL_SPECIAL_CHARS); | 230 net::UnescapeRule::URL_SPECIAL_CHARS); |
231 } while (unescaped_str != old_unescaped_str && ++loop_var <= | 231 } while (unescaped_str != old_unescaped_str && ++loop_var <= |
232 kMaxLoopIterations); | 232 kMaxLoopIterations); |
233 | 233 |
234 return unescaped_str; | 234 return unescaped_str; |
235 } | 235 } |
236 | 236 |
237 std::string Escape(const std::string& url) { | 237 std::string Escape(const std::string& url) { |
238 std::string escaped_str; | 238 std::string escaped_str; |
239 const char* kHexString = "0123456789ABCDEF"; | 239 const char* kHexString = "0123456789ABCDEF"; |
240 for (size_t i = 0; i < url.length(); i++) { | 240 for (size_t i = 0; i < url.length(); i++) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) { | 541 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out) { |
542 DCHECK_EQ(crypto::kSHA256Length, hash_in.size()); | 542 DCHECK_EQ(crypto::kSHA256Length, hash_in.size()); |
543 memcpy(hash_out->full_hash, hash_in.data(), crypto::kSHA256Length); | 543 memcpy(hash_out->full_hash, hash_in.data(), crypto::kSHA256Length); |
544 } | 544 } |
545 | 545 |
546 std::string SBFullHashToString(const SBFullHash& hash) { | 546 std::string SBFullHashToString(const SBFullHash& hash) { |
547 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); | 547 DCHECK_EQ(crypto::kSHA256Length, sizeof(hash.full_hash)); |
548 return std::string(hash.full_hash, sizeof(hash.full_hash)); | 548 return std::string(hash.full_hash, sizeof(hash.full_hash)); |
549 } | 549 } |
550 } // namespace safe_browsing_util | 550 } // namespace safe_browsing_util |
OLD | NEW |