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

Side by Side Diff: src/url_canon_unittest.cc

Issue 149588: Require hosts for non-file URLs. (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/url_canon_stdurl.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 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 url_parse::Component expected_username; 774 url_parse::Component expected_username;
775 url_parse::Component expected_password; 775 url_parse::Component expected_password;
776 bool expected_success; 776 bool expected_success;
777 } user_info_cases[] = { 777 } user_info_cases[] = {
778 {"http://user:pass@host.com/", "user:pass@", url_parse::Component(0, 4), url _parse::Component(5, 4), true}, 778 {"http://user:pass@host.com/", "user:pass@", url_parse::Component(0, 4), url _parse::Component(5, 4), true},
779 {"http://@host.com/", "", url_parse::Component(0, -1), url_parse::Component( 0, -1), true}, 779 {"http://@host.com/", "", url_parse::Component(0, -1), url_parse::Component( 0, -1), true},
780 {"http://:@host.com/", "", url_parse::Component(0, -1), url_parse::Component (0, -1), true}, 780 {"http://:@host.com/", "", url_parse::Component(0, -1), url_parse::Component (0, -1), true},
781 {"http://foo:@host.com/", "foo@", url_parse::Component(0, 3), url_parse::Com ponent(0, -1), true}, 781 {"http://foo:@host.com/", "foo@", url_parse::Component(0, 3), url_parse::Com ponent(0, -1), true},
782 {"http://:foo@host.com/", ":foo@", url_parse::Component(0, 0), url_parse::Co mponent(1, 3), true}, 782 {"http://:foo@host.com/", ":foo@", url_parse::Component(0, 0), url_parse::Co mponent(1, 3), true},
783 {"http://^ :$\t@host.com/", "%5E%20:$%09@", url_parse::Component(0, 6), url_ parse::Component(7, 4), true}, 783 {"http://^ :$\t@host.com/", "%5E%20:$%09@", url_parse::Component(0, 6), url_ parse::Component(7, 4), true},
784 {"http://user:pass@/", "user:pass@", url_parse::Component(0, 4), url_parse:: Component(5, 4), true},
784 785
785 // IE7 compatability: old versions allowed backslashes in usernames, but 786 // IE7 compatability: old versions allowed backslashes in usernames, but
786 // IE7 does not. We disallow it as well. 787 // IE7 does not. We disallow it as well.
787 {"ftp://me\\mydomain:pass@foo.com/", "", url_parse::Component(0, -1), url_pa rse::Component(0, -1), true}, 788 {"ftp://me\\mydomain:pass@foo.com/", "", url_parse::Component(0, -1), url_pa rse::Component(0, -1), true},
788 }; 789 };
789 790
790 for (size_t i = 0; i < ARRAYSIZE(user_info_cases); i++) { 791 for (size_t i = 0; i < ARRAYSIZE(user_info_cases); i++) {
791 int url_len = static_cast<int>(strlen(user_info_cases[i].input)); 792 int url_len = static_cast<int>(strlen(user_info_cases[i].input));
792 url_parse::Parsed parsed; 793 url_parse::Parsed parsed;
793 url_parse::ParseStandardURL(user_info_cases[i].input, url_len, &parsed); 794 url_parse::ParseStandardURL(user_info_cases[i].input, url_len, &parsed);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 const char* expected; 1177 const char* expected;
1177 bool expected_success; 1178 bool expected_success;
1178 } cases[] = { 1179 } cases[] = {
1179 {"http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#", true}, 1180 {"http://www.google.com/foo?bar=baz#", "http://www.google.com/foo?bar=baz#", true},
1180 {"http://[www.google.com]/", "http://[www.google.com]/", false}, 1181 {"http://[www.google.com]/", "http://[www.google.com]/", false},
1181 {"ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#", false }, 1182 {"ht\ttp:@www.google.com:80/;p?#", "ht%09tp://www.google.com:80/;p?#", false },
1182 {"http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo", t rue}, 1183 {"http:////////user:@google.com:99?foo", "http://user@google.com:99/?foo", t rue},
1183 {"www.google.com", ":www.google.com/", true}, 1184 {"www.google.com", ":www.google.com/", true},
1184 {"http://192.0x00A80001", "http://192.168.0.1/", true}, 1185 {"http://192.0x00A80001", "http://192.168.0.1/", true},
1185 {"http://www/foo%2Ehtml", "http://www/foo.html", true}, 1186 {"http://www/foo%2Ehtml", "http://www/foo.html", true},
1187 {"http://user:pass@/", "http://user:pass@/", false},
1186 1188
1187 // Backslashes should get converted to forward slashes. 1189 // Backslashes should get converted to forward slashes.
1188 {"http:\\\\www.google.com\\foo", "http://www.google.com/foo", true}, 1190 {"http:\\\\www.google.com\\foo", "http://www.google.com/foo", true},
1189 1191
1190 // Busted refs shouldn't make the whole thing fail. 1192 // Busted refs shouldn't make the whole thing fail.
1191 {"http://www.google.com/asdf#\xc2", "http://www.google.com/asdf#\xef\xbf\xbd ", true}, 1193 {"http://www.google.com/asdf#\xc2", "http://www.google.com/asdf#\xef\xbf\xbd ", true},
1192 1194
1193 // Basic port tests. 1195 // Basic port tests.
1194 {"http://foo:80/", "http://foo/", true}, 1196 {"http://foo:80/", "http://foo/", true},
1195 {"http://foo:81/", "http://foo:81/", true}, 1197 {"http://foo:81/", "http://foo:81/", true},
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 url_canon::StdStringCanonOutput repl_output(&repl_str); 1910 url_canon::StdStringCanonOutput repl_output(&repl_str);
1909 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ; 1911 url_canon::ReplaceFileURL(src, parsed, repl, NULL, &repl_output, &repl_parsed) ;
1910 repl_output.Complete(); 1912 repl_output.Complete();
1911 1913
1912 // Generate the expected string and check. 1914 // Generate the expected string and check.
1913 std::string expected("file:///foo?"); 1915 std::string expected("file:///foo?");
1914 for (size_t i = 0; i < new_query.length(); i++) 1916 for (size_t i = 0; i < new_query.length(); i++)
1915 expected.push_back('a'); 1917 expected.push_back('a');
1916 EXPECT_TRUE(expected == repl_str); 1918 EXPECT_TRUE(expected == repl_str);
1917 } 1919 }
OLDNEW
« no previous file with comments | « src/url_canon_stdurl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698