| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "net/base/escape.h" | 8 #include "net/base/escape.h" |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 const UnescapeURLCase unescape_cases[] = { | 211 const UnescapeURLCase unescape_cases[] = { |
| 212 {L"", UnescapeRule::NORMAL, L""}, | 212 {L"", UnescapeRule::NORMAL, L""}, |
| 213 {L"%2", UnescapeRule::NORMAL, L"%2"}, | 213 {L"%2", UnescapeRule::NORMAL, L"%2"}, |
| 214 {L"%%%%%%", UnescapeRule::NORMAL, L"%%%%%%"}, | 214 {L"%%%%%%", UnescapeRule::NORMAL, L"%%%%%%"}, |
| 215 {L"Don't escape anything", UnescapeRule::NORMAL, L"Don't escape anything"}, | 215 {L"Don't escape anything", UnescapeRule::NORMAL, L"Don't escape anything"}, |
| 216 {L"Invalid %escape %2", UnescapeRule::NORMAL, L"Invalid %escape %2"}, | 216 {L"Invalid %escape %2", UnescapeRule::NORMAL, L"Invalid %escape %2"}, |
| 217 {L"Some%20random text %25%2dOK", UnescapeRule::NONE, | 217 {L"Some%20random text %25%2dOK", UnescapeRule::NONE, |
| 218 L"Some%20random text %25%2dOK"}, | 218 L"Some%20random text %25%2dOK"}, |
| 219 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, | 219 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, |
| 220 L"Some%20random text %25-OK"}, | 220 L"Some%20random text %25-OK"}, |
| 221 {L"Some%20random text %25%E2%80", UnescapeRule::NORMAL, |
| 222 L"Some%20random text %25\xE2\x80"}, |
| 223 {L"Some%20random text %25%E2%80OK", UnescapeRule::NORMAL, |
| 224 L"Some%20random text %25\xE2\x80OK"}, |
| 225 {L"Some%20random text %25%E2%80%84OK", UnescapeRule::NORMAL, |
| 226 L"Some%20random text %25\xE2\x80\x84OK"}, |
| 227 |
| 228 // BiDi Control characters should not be unescaped. |
| 229 {L"Some%20random text %25%D8%9COK", UnescapeRule::NORMAL, |
| 230 L"Some%20random text %25%D8%9COK"}, |
| 231 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL, |
| 232 L"Some%20random text %25%E2%80%8EOK"}, |
| 233 {L"Some%20random text %25%E2%80%8FOK", UnescapeRule::NORMAL, |
| 234 L"Some%20random text %25%E2%80%8FOK"}, |
| 235 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL, |
| 236 L"Some%20random text %25%E2%80%AAOK"}, |
| 237 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL, |
| 238 L"Some%20random text %25%E2%80%ABOK"}, |
| 239 {L"Some%20random text %25%E2%80%AEOK", UnescapeRule::NORMAL, |
| 240 L"Some%20random text %25%E2%80%AEOK"}, |
| 241 {L"Some%20random text %25%E2%81%A6OK", UnescapeRule::NORMAL, |
| 242 L"Some%20random text %25%E2%81%A6OK"}, |
| 243 {L"Some%20random text %25%E2%81%A9OK", UnescapeRule::NORMAL, |
| 244 L"Some%20random text %25%E2%81%A9OK"}, |
| 245 |
| 221 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, | 246 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, |
| 222 L"Some random text %25-OK"}, | 247 L"Some random text %25-OK"}, |
| 223 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, | 248 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, |
| 224 L"Some%20random text %-OK"}, | 249 L"Some%20random text %-OK"}, |
| 225 {L"Some%20random text %25%2dOK", | 250 {L"Some%20random text %25%2dOK", |
| 226 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, | 251 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, |
| 227 L"Some random text %-OK"}, | 252 L"Some random text %-OK"}, |
| 228 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, | 253 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, |
| 229 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, | 254 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, |
| 230 // Certain URL-sensitive characters should not be unescaped unless asked. | 255 // Certain URL-sensitive characters should not be unescaped unless asked. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 internal::AdjustEncodingOffset(adjustments)); | 448 internal::AdjustEncodingOffset(adjustments)); |
| 424 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos, | 449 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos, |
| 425 kNpos, 6, 7, 8, 9, kNpos, kNpos}; | 450 kNpos, 6, 7, 8, 9, kNpos, kNpos}; |
| 426 EXPECT_EQ(offsets.size(), arraysize(expected_2)); | 451 EXPECT_EQ(offsets.size(), arraysize(expected_2)); |
| 427 for (size_t i = 0; i < arraysize(expected_2); ++i) | 452 for (size_t i = 0; i < arraysize(expected_2); ++i) |
| 428 EXPECT_EQ(expected_2[i], offsets[i]); | 453 EXPECT_EQ(expected_2[i], offsets[i]); |
| 429 } | 454 } |
| 430 | 455 |
| 431 } // namespace | 456 } // namespace |
| 432 } // namespace net | 457 } // namespace net |
| OLD | NEW |