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

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

Issue 339017: Loosen RFC 1738 compliance check to allow underscores where we already allowe... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/base/net_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 #include "net/base/escape.h" 10 #include "net/base/escape.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 true}}, 337 true}},
338 {"xn--fiqs8s.cn", L"\x4e2d\x56fd\x3002" L"cn", 338 {"xn--fiqs8s.cn", L"\x4e2d\x56fd\x3002" L"cn",
339 {false, false, true, false, false, 339 {false, false, true, false, false,
340 false, false, false, false, false, 340 false, false, false, false, false,
341 false, false, false, false, false, 341 false, false, false, false, false,
342 false, false, true, false, false, 342 false, false, true, false, false,
343 true}}, 343 true}},
344 #endif 344 #endif
345 }; 345 };
346 346
347 struct RFC1738Case { 347 struct CompliantHostCase {
348 const char* host; 348 const char* host;
349 bool expected_output; 349 bool expected_output;
350 }; 350 };
351 351
352 struct SuggestedFilenameCase { 352 struct SuggestedFilenameCase {
353 const char* url; 353 const char* url;
354 const char* content_disp_header; 354 const char* content_disp_header;
355 const char* referrer_charset; 355 const char* referrer_charset;
356 const char* default_filename; 356 const char* default_filename;
357 const wchar_t* expected_filename; 357 const wchar_t* expected_filename;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 &output); 808 &output);
809 std::wstring expected(idn_cases[i].unicode_allowed[j] ? 809 std::wstring expected(idn_cases[i].unicode_allowed[j] ?
810 idn_cases[i].unicode_output : 810 idn_cases[i].unicode_output :
811 ASCIIToWide(idn_cases[i].input)); 811 ASCIIToWide(idn_cases[i].input));
812 AppendLanguagesToOutputs(kLanguages[j], &expected, &output); 812 AppendLanguagesToOutputs(kLanguages[j], &expected, &output);
813 EXPECT_EQ(expected, output); 813 EXPECT_EQ(expected, output);
814 } 814 }
815 } 815 }
816 } 816 }
817 817
818 TEST(NetUtilTest, RFC1738) { 818 TEST(NetUtilTest, CompliantHost) {
819 const RFC1738Case rfc1738_cases[] = { 819 const CompliantHostCase compliant_host_cases[] = {
820 {"", false}, 820 {"", false},
821 {"a", true}, 821 {"a", true},
822 {"-", false}, 822 {"-", false},
823 {".", false}, 823 {".", false},
824 {"a.", false}, 824 {"a.", false},
825 {"a.a", true}, 825 {"a.a", true},
826 {"9.a", true}, 826 {"9.a", true},
827 {"a.9", false}, 827 {"a.9", false},
828 {"_9a", false},
828 {"a.a9", true}, 829 {"a.a9", true},
829 {"a.9a", false}, 830 {"a.9a", false},
830 {"a+9a", false}, 831 {"a+9a", false},
831 {"1-.a-b", false}, 832 {"1-.a-b", false},
832 {"1-2.a-b", true}, 833 {"1-2.a_b", true},
833 {"a.b.c.d.e", true}, 834 {"a.b.c.d.e", true},
834 {"1.2.3.4.e", true}, 835 {"1.2.3.4.e", true},
835 {"a.b.c.d.5", false}, 836 {"a.b.c.d.5", false},
836 }; 837 };
837 838
838 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(rfc1738_cases); ++i) { 839 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(compliant_host_cases); ++i) {
839 EXPECT_EQ(rfc1738_cases[i].expected_output, 840 EXPECT_EQ(compliant_host_cases[i].expected_output,
840 net::IsCanonicalizedHostRFC1738Compliant(rfc1738_cases[i].host)); 841 net::IsCanonicalizedHostCompliant(compliant_host_cases[i].host));
841 } 842 }
842 } 843 }
843 844
844 TEST(NetUtilTest, StripWWW) { 845 TEST(NetUtilTest, StripWWW) {
845 EXPECT_EQ(L"", net::StripWWW(L"")); 846 EXPECT_EQ(L"", net::StripWWW(L""));
846 EXPECT_EQ(L"", net::StripWWW(L"www.")); 847 EXPECT_EQ(L"", net::StripWWW(L"www."));
847 EXPECT_EQ(L"blah", net::StripWWW(L"www.blah")); 848 EXPECT_EQ(L"blah", net::StripWWW(L"www.blah"));
848 EXPECT_EQ(L"blah", net::StripWWW(L"blah")); 849 EXPECT_EQ(L"blah", net::StripWWW(L"blah"));
849 } 850 }
850 851
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 net::SetExplicitlyAllowedPorts(invalid[i]); 1440 net::SetExplicitlyAllowedPorts(invalid[i]);
1440 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size())); 1441 EXPECT_EQ(0, static_cast<int>(net::explicitly_allowed_ports.size()));
1441 } 1442 }
1442 1443
1443 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) { 1444 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(valid); ++i) {
1444 net::SetExplicitlyAllowedPorts(valid[i]); 1445 net::SetExplicitlyAllowedPorts(valid[i]);
1445 EXPECT_EQ(i, net::explicitly_allowed_ports.size()); 1446 EXPECT_EQ(i, net::explicitly_allowed_ports.size());
1446 } 1447 }
1447 } 1448 }
1448 1449
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698