| 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" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace | 186 } // namespace |
| 187 | 187 |
| 188 // Everything except alphanumerics and !'()*-._~ | 188 // Everything except alphanumerics and !'()*-._~ |
| 189 // See RFC 2396 for the list of reserved characters. | 189 // See RFC 2396 for the list of reserved characters. |
| 190 static const Charmap kQueryCharmap( | 190 static const Charmap kQueryCharmap( |
| 191 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, | 191 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, |
| 192 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 192 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 193 | 193 |
| 194 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { | |
| 195 return Escape(text, kQueryCharmap, use_plus); | |
| 196 } | |
| 197 | |
| 198 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} | 194 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} |
| 199 static const Charmap kPathCharmap( | 195 static const Charmap kPathCharmap( |
| 200 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L, | 196 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L, |
| 201 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 197 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 202 | 198 |
| 203 std::string EscapePath(const std::string& path) { | 199 std::string EscapePath(const std::string& path) { |
| 204 return Escape(path, kPathCharmap, false); | 200 return Escape(path, kPathCharmap, false); |
| 205 } | 201 } |
| 206 | 202 |
| 207 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} | 203 // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 break; | 353 break; |
| 358 } | 354 } |
| 359 } | 355 } |
| 360 } | 356 } |
| 361 } | 357 } |
| 362 return text; | 358 return text; |
| 363 } | 359 } |
| 364 | 360 |
| 365 namespace net { | 361 namespace net { |
| 366 | 362 |
| 363 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { |
| 364 return Escape(text, kQueryCharmap, use_plus); |
| 365 } |
| 366 |
| 367 // Convert the string to a sequence of bytes and then % escape anything | 367 // Convert the string to a sequence of bytes and then % escape anything |
| 368 // except alphanumerics and !'()*-._~ | 368 // except alphanumerics and !'()*-._~ |
| 369 string16 EscapeQueryParamValueUTF8(const string16& text, bool use_plus) { | 369 string16 EscapeQueryParamValueUTF8(const string16& text, bool use_plus) { |
| 370 return UTF8ToUTF16(Escape(UTF16ToUTF8(text), kQueryCharmap, use_plus)); | 370 return UTF8ToUTF16(Escape(UTF16ToUTF8(text), kQueryCharmap, use_plus)); |
| 371 } | 371 } |
| 372 | 372 |
| 373 namespace internal { | 373 namespace internal { |
| 374 | 374 |
| 375 AdjustEncodingOffset::AdjustEncodingOffset(const Adjustments& adjustments) | 375 AdjustEncodingOffset::AdjustEncodingOffset(const Adjustments& adjustments) |
| 376 : adjustments(adjustments) {} | 376 : adjustments(adjustments) {} |
| (...skipping 15 matching lines...) Expand all Loading... |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 adjusted_offset -= 2; | 394 adjusted_offset -= 2; |
| 395 } | 395 } |
| 396 offset = adjusted_offset; | 396 offset = adjusted_offset; |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace internal | 399 } // namespace internal |
| 400 | 400 |
| 401 } // namespace net | 401 } // namespace net |
| OLD | NEW |