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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 L"Some%20random text %25%2dOK"}, | 225 L"Some%20random text %25%2dOK"}, |
226 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, | 226 {L"Some%20random text %25%2dOK", UnescapeRule::NORMAL, |
227 L"Some%20random text %25-OK"}, | 227 L"Some%20random text %25-OK"}, |
228 {L"Some%20random text %25%E2%80", UnescapeRule::NORMAL, | 228 {L"Some%20random text %25%E2%80", UnescapeRule::NORMAL, |
229 L"Some%20random text %25\xE2\x80"}, | 229 L"Some%20random text %25\xE2\x80"}, |
230 {L"Some%20random text %25%E2%80OK", UnescapeRule::NORMAL, | 230 {L"Some%20random text %25%E2%80OK", UnescapeRule::NORMAL, |
231 L"Some%20random text %25\xE2\x80OK"}, | 231 L"Some%20random text %25\xE2\x80OK"}, |
232 {L"Some%20random text %25%E2%80%84OK", UnescapeRule::NORMAL, | 232 {L"Some%20random text %25%E2%80%84OK", UnescapeRule::NORMAL, |
233 L"Some%20random text %25\xE2\x80\x84OK"}, | 233 L"Some%20random text %25\xE2\x80\x84OK"}, |
234 | 234 |
235 // BiDi Control characters should not be unescaped. | 235 // BiDi Control characters should not be unescaped unless explicity told to |
| 236 // do so with UnescapeRule::CONTROL_CHARS |
236 {L"Some%20random text %25%D8%9COK", UnescapeRule::NORMAL, | 237 {L"Some%20random text %25%D8%9COK", UnescapeRule::NORMAL, |
237 L"Some%20random text %25%D8%9COK"}, | 238 L"Some%20random text %25%D8%9COK"}, |
238 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL, | 239 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL, |
239 L"Some%20random text %25%E2%80%8EOK"}, | 240 L"Some%20random text %25%E2%80%8EOK"}, |
240 {L"Some%20random text %25%E2%80%8FOK", UnescapeRule::NORMAL, | 241 {L"Some%20random text %25%E2%80%8FOK", UnescapeRule::NORMAL, |
241 L"Some%20random text %25%E2%80%8FOK"}, | 242 L"Some%20random text %25%E2%80%8FOK"}, |
242 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL, | 243 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL, |
243 L"Some%20random text %25%E2%80%AAOK"}, | 244 L"Some%20random text %25%E2%80%AAOK"}, |
244 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL, | 245 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL, |
245 L"Some%20random text %25%E2%80%ABOK"}, | 246 L"Some%20random text %25%E2%80%ABOK"}, |
246 {L"Some%20random text %25%E2%80%AEOK", UnescapeRule::NORMAL, | 247 {L"Some%20random text %25%E2%80%AEOK", UnescapeRule::NORMAL, |
247 L"Some%20random text %25%E2%80%AEOK"}, | 248 L"Some%20random text %25%E2%80%AEOK"}, |
248 {L"Some%20random text %25%E2%81%A6OK", UnescapeRule::NORMAL, | 249 {L"Some%20random text %25%E2%81%A6OK", UnescapeRule::NORMAL, |
249 L"Some%20random text %25%E2%81%A6OK"}, | 250 L"Some%20random text %25%E2%81%A6OK"}, |
250 {L"Some%20random text %25%E2%81%A9OK", UnescapeRule::NORMAL, | 251 {L"Some%20random text %25%E2%81%A9OK", UnescapeRule::NORMAL, |
251 L"Some%20random text %25%E2%81%A9OK"}, | 252 L"Some%20random text %25%E2%81%A9OK"}, |
| 253 // UnescapeRule::CONTROL_CHARS should unescape BiDi Control characters. |
| 254 {L"Some%20random text %25%D8%9COK", |
| 255 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 256 L"Some%20random text %25\xD8\x9COK"}, |
| 257 {L"Some%20random text %25%E2%80%8EOK", |
| 258 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 259 L"Some%20random text %25\xE2\x80\x8EOK"}, |
| 260 {L"Some%20random text %25%E2%80%8FOK", |
| 261 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 262 L"Some%20random text %25\xE2\x80\x8FOK"}, |
| 263 {L"Some%20random text %25%E2%80%AAOK", |
| 264 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 265 L"Some%20random text %25\xE2\x80\xAAOK"}, |
| 266 {L"Some%20random text %25%E2%80%ABOK", |
| 267 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 268 L"Some%20random text %25\xE2\x80\xABOK"}, |
| 269 {L"Some%20random text %25%E2%80%AEOK", |
| 270 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 271 L"Some%20random text %25\xE2\x80\xAEOK"}, |
| 272 {L"Some%20random text %25%E2%81%A6OK", |
| 273 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 274 L"Some%20random text %25\xE2\x81\xA6OK"}, |
| 275 {L"Some%20random text %25%E2%81%A9OK", |
| 276 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 277 L"Some%20random text %25\xE2\x81\xA9OK"}, |
252 | 278 |
253 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, | 279 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, |
254 L"Some random text %25-OK"}, | 280 L"Some random text %25-OK"}, |
255 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, | 281 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, |
256 L"Some%20random text %-OK"}, | 282 L"Some%20random text %-OK"}, |
257 {L"Some%20random text %25%2dOK", | 283 {L"Some%20random text %25%2dOK", |
258 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, | 284 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, |
259 L"Some random text %-OK"}, | 285 L"Some random text %-OK"}, |
260 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, | 286 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, |
261 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, | 287 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 }; | 475 }; |
450 for (size_t i = 0; i < arraysize(tests); ++i) { | 476 for (size_t i = 0; i < arraysize(tests); ++i) { |
451 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input)); | 477 base::string16 result = UnescapeForHTML(base::ASCIIToUTF16(tests[i].input)); |
452 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result); | 478 EXPECT_EQ(base::ASCIIToUTF16(tests[i].expected_output), result); |
453 } | 479 } |
454 } | 480 } |
455 | 481 |
456 | 482 |
457 } // namespace | 483 } // namespace |
458 } // namespace net | 484 } // namespace net |
OLD | NEW |