| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "net/base/escape.h" | 7 #include "net/base/escape.h" |
| 8 | 8 |
| 9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 static const Charmap kQueryCharmap( | 185 static const Charmap kQueryCharmap( |
| 186 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, | 186 0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, |
| 187 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 187 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 188 | 188 |
| 189 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { | 189 std::string EscapeQueryParamValue(const std::string& text, bool use_plus) { |
| 190 return Escape(text, kQueryCharmap, use_plus); | 190 return Escape(text, kQueryCharmap, use_plus); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Convert the string to a sequence of bytes and then % escape anything | 193 // Convert the string to a sequence of bytes and then % escape anything |
| 194 // except alphanumerics and !'()*-._~ | 194 // except alphanumerics and !'()*-._~ |
| 195 string16 EscapeQueryParamValueUTF8(const string16& text, | 195 std::wstring EscapeQueryParamValueUTF8(const std::wstring& text, |
| 196 bool use_plus) { | 196 bool use_plus) { |
| 197 return UTF8ToUTF16(Escape(UTF16ToUTF8(text), kQueryCharmap, use_plus)); | 197 return UTF8ToWide(Escape(WideToUTF8(text), kQueryCharmap, use_plus)); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} | 200 // non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} |
| 201 static const Charmap kPathCharmap( | 201 static const Charmap kPathCharmap( |
| 202 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L, | 202 0xffffffffL, 0xd400002dL, 0x78000000L, 0xb8000001L, |
| 203 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); | 203 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL); |
| 204 | 204 |
| 205 std::string EscapePath(const std::string& path) { | 205 std::string EscapePath(const std::string& path) { |
| 206 return Escape(path, kPathCharmap, false); | 206 return Escape(path, kPathCharmap, false); |
| 207 } | 207 } |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 if (text.find(ampersand_chars[i], index) == index) { | 357 if (text.find(ampersand_chars[i], index) == index) { |
| 358 text.replace(iter, iter + ampersand_chars[i].length(), | 358 text.replace(iter, iter + ampersand_chars[i].length(), |
| 359 1, kEscapeToChars[i].replacement); | 359 1, kEscapeToChars[i].replacement); |
| 360 break; | 360 break; |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 return text; | 365 return text; |
| 366 } | 366 } |
| OLD | NEW |