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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 {L"Some%20random text %25%E2%80%AEOK", | 269 {L"Some%20random text %25%E2%80%AEOK", |
270 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 270 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
271 L"Some%20random text %25\xE2\x80\xAEOK"}, | 271 L"Some%20random text %25\xE2\x80\xAEOK"}, |
272 {L"Some%20random text %25%E2%81%A6OK", | 272 {L"Some%20random text %25%E2%81%A6OK", |
273 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 273 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
274 L"Some%20random text %25\xE2\x81\xA6OK"}, | 274 L"Some%20random text %25\xE2\x81\xA6OK"}, |
275 {L"Some%20random text %25%E2%81%A9OK", | 275 {L"Some%20random text %25%E2%81%A9OK", |
276 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, | 276 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
277 L"Some%20random text %25\xE2\x81\xA9OK"}, | 277 L"Some%20random text %25\xE2\x81\xA9OK"}, |
278 | 278 |
| 279 // Certain banned characters should not be unescaped unless explicitly told |
| 280 // to do so with UnescapeRule::CONTROL_CHARS. |
| 281 // U+1F50F LOCK WITH INK PEN |
| 282 {L"Some%20random text %25%F0%9F%94%8FOK", UnescapeRule::NORMAL, |
| 283 L"Some%20random text %25%F0%9F%94%8FOK"}, |
| 284 // U+1F510 CLOSED LOCK WITH KEY |
| 285 {L"Some%20random text %25%F0%9F%94%90OK", UnescapeRule::NORMAL, |
| 286 L"Some%20random text %25%F0%9F%94%90OK"}, |
| 287 // U+1F512 LOCK |
| 288 {L"Some%20random text %25%F0%9F%94%92OK", UnescapeRule::NORMAL, |
| 289 L"Some%20random text %25%F0%9F%94%92OK"}, |
| 290 // U+1F513 OPEN LOCK |
| 291 {L"Some%20random text %25%F0%9F%94%93OK", UnescapeRule::NORMAL, |
| 292 L"Some%20random text %25%F0%9F%94%93OK"}, |
| 293 // UnescapeRule::CONTROL_CHARS should unescape banned characters. |
| 294 {L"Some%20random text %25%F0%9F%94%8FOK", |
| 295 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 296 L"Some%20random text %25\xF0\x9F\x94\x8FOK"}, |
| 297 {L"Some%20random text %25%F0%9F%94%90OK", |
| 298 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 299 L"Some%20random text %25\xF0\x9F\x94\x90OK"}, |
| 300 {L"Some%20random text %25%F0%9F%94%92OK", |
| 301 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 302 L"Some%20random text %25\xF0\x9F\x94\x92OK"}, |
| 303 {L"Some%20random text %25%F0%9F%94%93OK", |
| 304 UnescapeRule::NORMAL | UnescapeRule::CONTROL_CHARS, |
| 305 L"Some%20random text %25\xF0\x9F\x94\x93OK"}, |
| 306 |
279 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, | 307 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, |
280 L"Some random text %25-OK"}, | 308 L"Some random text %25-OK"}, |
281 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, | 309 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, |
282 L"Some%20random text %-OK"}, | 310 L"Some%20random text %-OK"}, |
283 {L"Some%20random text %25%2dOK", | 311 {L"Some%20random text %25%2dOK", |
284 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, | 312 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, |
285 L"Some random text %-OK"}, | 313 L"Some random text %-OK"}, |
286 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, | 314 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, |
287 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, | 315 {L"%Aa%Bb%Cc%Dd%Ee%Ff", UnescapeRule::NORMAL, L"\xAa\xBb\xCc\xDd\xEe\xFf"}, |
288 // Certain URL-sensitive characters should not be unescaped unless asked. | 316 // Certain URL-sensitive characters should not be unescaped unless asked. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|")); | 540 "http://example.com/path/sub?q=a|b|c&q=1|2|3#ref|")); |
513 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", | 541 ASSERT_EQ("http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C", |
514 EscapeExternalHandlerValue( | 542 EscapeExternalHandlerValue( |
515 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C")); | 543 "http://example.com/path/sub?q=a%7Cb%7Cc&q=1%7C2%7C3#ref%7C")); |
516 ASSERT_EQ("http://[2001:db8:0:1]:80", | 544 ASSERT_EQ("http://[2001:db8:0:1]:80", |
517 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80")); | 545 EscapeExternalHandlerValue("http://[2001:db8:0:1]:80")); |
518 } | 546 } |
519 | 547 |
520 } // namespace | 548 } // namespace |
521 } // namespace net | 549 } // namespace net |
OLD | NEW |