Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: net/base/escape_unittest.cc

Issue 181483008: Don't unescape BiDi control characters in URL components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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%83OK", UnescapeRule::NORMAL,
222 L"Some%20random text %25\xE2\x80\x83OK"},
223
224 // BiDi Control characters should not be unescaped.
225 {L"Some%20random text %25%E2%80%8EOK", UnescapeRule::NORMAL,
226 L"Some%20random text %25%E2%80%8EOK"},
227 {L"Some%20random text %25%E2%80%AAOK", UnescapeRule::NORMAL,
228 L"Some%20random text %25%E2%80%AAOK"},
229 {L"Some%20random text %25%E2%80%ABOK", UnescapeRule::NORMAL,
230 L"Some%20random text %25%E2%80%ABOK"},
231
221 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES, 232 {L"Some%20random text %25%2dOK", UnescapeRule::SPACES,
222 L"Some random text %25-OK"}, 233 L"Some random text %25-OK"},
223 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS, 234 {L"Some%20random text %25%2dOK", UnescapeRule::URL_SPECIAL_CHARS,
224 L"Some%20random text %-OK"}, 235 L"Some%20random text %-OK"},
225 {L"Some%20random text %25%2dOK", 236 {L"Some%20random text %25%2dOK",
226 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, 237 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS,
227 L"Some random text %-OK"}, 238 L"Some random text %-OK"},
228 {L"%A0%B1%C2%D3%E4%F5", UnescapeRule::NORMAL, L"\xA0\xB1\xC2\xD3\xE4\xF5"}, 239 {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"}, 240 {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. 241 // Certain URL-sensitive characters should not be unescaped unless asked.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 internal::AdjustEncodingOffset(adjustments)); 434 internal::AdjustEncodingOffset(adjustments));
424 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos, 435 size_t expected_2[] = {0, kNpos, kNpos, 1, 2, 3, 4, kNpos, kNpos, 5, kNpos,
425 kNpos, 6, 7, 8, 9, kNpos, kNpos}; 436 kNpos, 6, 7, 8, 9, kNpos, kNpos};
426 EXPECT_EQ(offsets.size(), arraysize(expected_2)); 437 EXPECT_EQ(offsets.size(), arraysize(expected_2));
427 for (size_t i = 0; i < arraysize(expected_2); ++i) 438 for (size_t i = 0; i < arraysize(expected_2); ++i)
428 EXPECT_EQ(expected_2[i], offsets[i]); 439 EXPECT_EQ(expected_2[i], offsets[i]);
429 } 440 }
430 441
431 } // namespace 442 } // namespace
432 } // namespace net 443 } // namespace net
OLDNEW
« net/base/escape.cc ('K') | « net/base/escape.cc ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698