| 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 "net/base/escape.h" | 5 #include "net/base/escape.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_offset_string_conversions.h" | 13 #include "base/utf_offset_string_conversions.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 | 15 |
| 16 namespace net { |
| 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 const char kHexString[] = "0123456789ABCDEF"; | 20 const char kHexString[] = "0123456789ABCDEF"; |
| 19 inline char IntToHex(int i) { | 21 inline char IntToHex(int i) { |
| 20 DCHECK_GE(i, 0) << i << " not a hex value"; | 22 DCHECK_GE(i, 0) << i << " not a hex value"; |
| 21 DCHECK_LE(i, 15) << i << " not a hex value"; | 23 DCHECK_LE(i, 15) << i << " not a hex value"; |
| 22 return kHexString[i]; | 24 return kHexString[i]; |
| 23 } | 25 } |
| 24 | 26 |
| 25 // A fast bit-vector map for ascii characters. | 27 // A fast bit-vector map for ascii characters. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 244 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 243 | 245 |
| 244 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and | 246 // Everything except alphanumerics, the reserved characters(;/?:@&=+$,) and |
| 245 // !'()*-._~% | 247 // !'()*-._~% |
| 246 static const Charmap kExternalHandlerCharmap( | 248 static const Charmap kExternalHandlerCharmap( |
| 247 0xffffffffL, 0x5000080dL, 0x68000000L, 0xb8000001L, | 249 0xffffffffL, 0x5000080dL, 0x68000000L, 0xb8000001L, |
| 248 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 250 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 249 | 251 |
| 250 } // namespace | 252 } // namespace |
| 251 | 253 |
| 252 namespace net { | |
| 253 | |
| 254 std::string EscapePath(const std::string& path) { | 254 std::string EscapePath(const std::string& path) { |
| 255 return Escape(path, kPathCharmap, false); | 255 return Escape(path, kPathCharmap, false); |
| 256 } | 256 } |
| 257 | 257 |
| 258 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) { | 258 std::string EscapeUrlEncodedData(const std::string& path, bool use_plus) { |
| 259 return Escape(path, kUrlEscape, use_plus); | 259 return Escape(path, kUrlEscape, use_plus); |
| 260 } | 260 } |
| 261 | 261 |
| 262 std::string EscapeNonASCII(const std::string& input) { | 262 std::string EscapeNonASCII(const std::string& input) { |
| 263 return Escape(input, kNonASCIICharmap, false); | 263 return Escape(input, kNonASCIICharmap, false); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 adjusted_offset -= 2; | 392 adjusted_offset -= 2; |
| 393 } | 393 } |
| 394 offset = adjusted_offset; | 394 offset = adjusted_offset; |
| 395 } | 395 } |
| 396 | 396 |
| 397 } // namespace internal | 397 } // namespace internal |
| 398 | 398 |
| 399 } // namespace net | 399 } // namespace net |
| OLD | NEW |