blob: 040593582a80ae56a6a460f0b7eb2f7772e48134 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
5#include <stdlib.h>
initial.commit09911bf2008-07-26 23:55:296
7#include "base/basictypes.h"
[email protected]b1c33f82009-01-23 01:51:238#include "base/file_util.h"
initial.commit09911bf2008-07-26 23:55:299#include "base/path_service.h"
10#include "base/string_util.h"
[email protected]f870a322009-01-16 21:47:2711#include "chrome/browser/net/url_fixer_upper.h"
initial.commit09911bf2008-07-26 23:55:2912#include "chrome/common/chrome_paths.h"
13#include "googleurl/src/url_parse.h"
14#include "googleurl/src/gurl.h"
15#include "net/base/net_util.h"
16#include "testing/gtest/include/gtest/gtest.h"
17
18namespace {
19 class URLFixerUpperTest : public testing::Test {
20 };
21};
22
23std::ostream& operator<<(std::ostream& os, const url_parse::Component& part) {
24 return os << "(begin=" << part.begin << ", len=" << part.len << ")";
25}
26
27struct segment_case {
[email protected]b1c33f82009-01-23 01:51:2328 const std::string input;
29 const std::string result;
initial.commit09911bf2008-07-26 23:55:2930 const url_parse::Component scheme;
31 const url_parse::Component username;
32 const url_parse::Component password;
33 const url_parse::Component host;
34 const url_parse::Component port;
35 const url_parse::Component path;
36 const url_parse::Component query;
37 const url_parse::Component ref;
38};
39
40static const segment_case segment_cases[] = {
[email protected]b1c33f82009-01-23 01:51:2341 { "http://www.google.com/", "http",
initial.commit09911bf2008-07-26 23:55:2942 url_parse::Component(0, 4), // scheme
43 url_parse::Component(), // username
44 url_parse::Component(), // password
45 url_parse::Component(7, 14), // host
46 url_parse::Component(), // port
47 url_parse::Component(21, 1), // path
48 url_parse::Component(), // query
49 url_parse::Component(), // ref
50 },
[email protected]b1c33f82009-01-23 01:51:2351 { "aBoUt:vErSiOn", "about",
initial.commit09911bf2008-07-26 23:55:2952 url_parse::Component(0, 5), // scheme
53 url_parse::Component(), // username
54 url_parse::Component(), // password
55 url_parse::Component(), // host
56 url_parse::Component(), // port
57 url_parse::Component(), // path
58 url_parse::Component(), // query
59 url_parse::Component(), // ref
60 },
[email protected]b1c33f82009-01-23 01:51:2361 { " www.google.com:124?foo#", "http",
initial.commit09911bf2008-07-26 23:55:2962 url_parse::Component(), // scheme
63 url_parse::Component(), // username
64 url_parse::Component(), // password
65 url_parse::Component(4, 14), // host
66 url_parse::Component(19, 3), // port
67 url_parse::Component(), // path
68 url_parse::Component(23, 3), // query
69 url_parse::Component(27, 0), // ref
70 },
[email protected]b1c33f82009-01-23 01:51:2371 { "[email protected]", "http",
initial.commit09911bf2008-07-26 23:55:2972 url_parse::Component(), // scheme
73 url_parse::Component(0, 4), // username
74 url_parse::Component(), // password
75 url_parse::Component(5, 14), // host
76 url_parse::Component(), // port
77 url_parse::Component(), // path
78 url_parse::Component(), // query
79 url_parse::Component(), // ref
80 },
[email protected]b1c33f82009-01-23 01:51:2381 { "ftp:/user:P:[email protected]...::23///pub?foo#bar", "ftp",
initial.commit09911bf2008-07-26 23:55:2982 url_parse::Component(0, 3), // scheme
83 url_parse::Component(5, 4), // username
84 url_parse::Component(10, 7), // password
85 url_parse::Component(18, 20), // host
86 url_parse::Component(39, 2), // port
87 url_parse::Component(41, 6), // path
88 url_parse::Component(48, 3), // query
89 url_parse::Component(52, 3), // ref
90 },
[email protected]818071ce2009-05-18 01:25:2591 { "[2001:db8::1]/path", "http",
92 url_parse::Component(), // scheme
93 url_parse::Component(), // username
94 url_parse::Component(), // password
95 url_parse::Component(0, 13), // host
96 url_parse::Component(), // port
97 url_parse::Component(13, 5), // path
98 url_parse::Component(), // query
99 url_parse::Component(), // ref
100 },
101 { "[::1]", "http",
102 url_parse::Component(), // scheme
103 url_parse::Component(), // username
104 url_parse::Component(), // password
105 url_parse::Component(0, 5), // host
106 url_parse::Component(), // port
107 url_parse::Component(), // path
108 url_parse::Component(), // query
109 url_parse::Component(), // ref
110 },
initial.commit09911bf2008-07-26 23:55:29111};
112
113TEST(URLFixerUpperTest, SegmentURL) {
[email protected]b1c33f82009-01-23 01:51:23114 std::string result;
initial.commit09911bf2008-07-26 23:55:29115 url_parse::Parsed parts;
116
[email protected]b1c33f82009-01-23 01:51:23117 for (size_t i = 0; i < arraysize(segment_cases); ++i) {
initial.commit09911bf2008-07-26 23:55:29118 segment_case value = segment_cases[i];
119 result = URLFixerUpper::SegmentURL(value.input, &parts);
120 EXPECT_EQ(value.result, result);
121 EXPECT_EQ(value.scheme, parts.scheme);
122 EXPECT_EQ(value.username, parts.username);
123 EXPECT_EQ(value.password, parts.password);
124 EXPECT_EQ(value.host, parts.host);
125 EXPECT_EQ(value.port, parts.port);
126 EXPECT_EQ(value.path, parts.path);
127 EXPECT_EQ(value.query, parts.query);
128 EXPECT_EQ(value.ref, parts.ref);
129 }
130}
131
132// Creates a file and returns its full name as well as the decomposed
133// version. Example:
134// full_path = "c:\foo\bar.txt"
135// dir = "c:\foo"
136// file_name = "bar.txt"
[email protected]b1c33f82009-01-23 01:51:23137static bool MakeTempFile(const FilePath& dir,
138 const FilePath& file_name,
139 FilePath* full_path) {
140 *full_path = dir.Append(file_name);
141 return file_util::WriteFile(full_path->ToWStringHack(), NULL, 0) == 0;
initial.commit09911bf2008-07-26 23:55:29142}
143
144// Returns true if the given URL is a file: URL that matches the given file
[email protected]b1c33f82009-01-23 01:51:23145static bool IsMatchingFileURL(const std::string& url,
146 const FilePath& full_file_path) {
initial.commit09911bf2008-07-26 23:55:29147 if (url.length() <= 8)
148 return false;
[email protected]b1c33f82009-01-23 01:51:23149 if (std::string("file:///") != url.substr(0, 8))
initial.commit09911bf2008-07-26 23:55:29150 return false; // no file:/// prefix
[email protected]b1c33f82009-01-23 01:51:23151 if (url.find('\\') != std::string::npos)
initial.commit09911bf2008-07-26 23:55:29152 return false; // contains backslashes
153
[email protected]b1c33f82009-01-23 01:51:23154 FilePath derived_path;
[email protected]56741852008-12-17 19:04:50155 net::FileURLToFilePath(GURL(url), &derived_path);
[email protected]b1c33f82009-01-23 01:51:23156
157 FilePath::StringType derived_path_str = derived_path.value();
158 return (derived_path_str.length() == full_file_path.value().length()) &&
159 std::equal(derived_path_str.begin(),
160 derived_path_str.end(),
161 full_file_path.value().begin(),
162 CaseInsensitiveCompare<FilePath::CharType>());
initial.commit09911bf2008-07-26 23:55:29163}
164
165struct fixup_case {
[email protected]b1c33f82009-01-23 01:51:23166 const std::string input;
167 const std::string desired_tld;
168 const std::string output;
initial.commit09911bf2008-07-26 23:55:29169} fixup_cases[] = {
[email protected]b1c33f82009-01-23 01:51:23170 {"www.google.com", "", "http://www.google.com/"},
171 {" www.google.com ", "", "http://www.google.com/"},
172 {" foo.com/asdf bar", "", "http://foo.com/asdf bar"},
173 {"..www.google.com..", "", "http://www.google.com./"},
174 {"http://......", "", "http://....../"},
175 {"http://host.com:ninety-two/", "", "http://host.com/"},
176 {"http://host.com:ninety-two?foo", "", "http://host.com/?foo"},
177 {"google.com:123", "", "http://google.com:123/"},
178 {"about:", "", "about:"},
179 {"about:version", "", "about:version"},
180 {"www:123", "", "http://www:123/"},
181 {" www:123", "", "http://www:123/"},
182 {"www.google.com?foo", "", "http://www.google.com/?foo"},
183 {"www.google.com#foo", "", "http://www.google.com/#foo"},
184 {"www.google.com?", "", "http://www.google.com/?"},
185 {"www.google.com#", "", "http://www.google.com/#"},
186 {"www.google.com:123?foo#bar", "", "http://www.google.com:123/?foo#bar"},
187 {"[email protected]", "", "http://[email protected]/"},
188 {"\xE6\xB0\xB4.com" , "", "http://\xE6\xB0\xB4.com/"},
initial.commit09911bf2008-07-26 23:55:29189 // It would be better if this next case got treated as http, but I don't see
190 // a clean way to guess this isn't the new-and-exciting "user" scheme.
[email protected]b1c33f82009-01-23 01:51:23191 {"user:[email protected]:8080/", "", "user:[email protected]:8080/"},
192 //{"file:///c:/foo/bar%20baz.txt", "", "file:///C:/foo/bar%20baz.txt"},
193 {"ftp.google.com", "", "ftp://ftp.google.com/"},
194 {" ftp.google.com", "", "ftp://ftp.google.com/"},
195 {"FTP.GooGle.com", "", "ftp://FTP.GooGle.com/"},
196 {"ftpblah.google.com", "", "http://ftpblah.google.com/"},
197 {"ftp", "", "http://ftp/"},
198 {"google.ftp.com", "", "http://google.ftp.com/"},
[email protected]90f933a2009-03-05 03:41:51199 // URLs which end with 0x85 (NEL in ISO-8859).
200 { "http://google.com/search?q=\xd0\x85", "",
201 "http://google.com/search?q=\xd0\x85"
202 },
203 { "http://google.com/search?q=\xec\x97\x85", "",
204 "http://google.com/search?q=\xec\x97\x85"
205 },
206 { "http://google.com/search?q=\xf0\x90\x80\x85", "",
207 "http://google.com/search?q=\xf0\x90\x80\x85"
208 },
209 // URLs which end with 0xA0 (non-break space in ISO-8859).
210 { "http://google.com/search?q=\xd0\xa0", "",
211 "http://google.com/search?q=\xd0\xa0"
212 },
213 { "http://google.com/search?q=\xec\x97\xa0", "",
214 "http://google.com/search?q=\xec\x97\xa0"
215 },
216 { "http://google.com/search?q=\xf0\x90\x80\xa0", "",
217 "http://google.com/search?q=\xf0\x90\x80\xa0"
218 },
[email protected]818071ce2009-05-18 01:25:25219 // URLs containing IPv6 literals.
220 {"[2001:db8::2]", "", "http://[2001:db8::2]/"},
221 {"[::]:80", "", "http://[::]:80/"},
222 {"[::]:80/path", "", "http://[::]:80/path"},
223 // TODO(pmarks): Maybe we should parse bare IPv6 literals someday.
224 {"::1", "", "::1"},
initial.commit09911bf2008-07-26 23:55:29225};
226
227TEST(URLFixerUpperTest, FixupURL) {
[email protected]b1c33f82009-01-23 01:51:23228 std::string output;
initial.commit09911bf2008-07-26 23:55:29229
[email protected]b1c33f82009-01-23 01:51:23230 for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
initial.commit09911bf2008-07-26 23:55:29231 fixup_case value = fixup_cases[i];
232 output = URLFixerUpper::FixupURL(value.input, value.desired_tld);
233 EXPECT_EQ(value.output, output);
234 }
235
236 // Check the TLD-appending functionality
237 fixup_case tld_cases[] = {
[email protected]b1c33f82009-01-23 01:51:23238 {"google", "com", "http://www.google.com/"},
239 {"google.", "com", "http://www.google.com/"},
240 {"google..", "com", "http://www.google.com/"},
241 {".google", "com", "http://www.google.com/"},
242 {"www.google", "com", "http://www.google.com/"},
243 {"google.com", "com", "http://google.com/"},
244 {"http://google", "com", "http://www.google.com/"},
245 {"..google..", "com", "http://www.google.com/"},
246 {"http://www.google", "com", "http://www.google.com/"},
247 {"google/foo", "com", "http://www.google.com/foo"},
248 {"google.com/foo", "com", "http://google.com/foo"},
249 {"google/?foo=.com", "com", "http://www.google.com/?foo=.com"},
250 {"www.google/?foo=www.", "com", "http://www.google.com/?foo=www."},
251 {"google.com/?foo=.com", "com", "http://google.com/?foo=.com"},
252 {"http://www.google.com", "com", "http://www.google.com/"},
253 {"google:123", "com", "http://www.google.com:123/"},
254 {"http://google:123", "com", "http://www.google.com:123/"},
initial.commit09911bf2008-07-26 23:55:29255 };
[email protected]b1c33f82009-01-23 01:51:23256 for (size_t i = 0; i < arraysize(tld_cases); ++i) {
initial.commit09911bf2008-07-26 23:55:29257 fixup_case value = tld_cases[i];
258 output = URLFixerUpper::FixupURL(value.input, value.desired_tld);
259 EXPECT_EQ(value.output, output);
260 }
261}
262
263// Test different types of file inputs to URIFixerUpper::FixupURL. This
264// doesn't go into the nice array of fixups above since the file input
265// has to exist.
266TEST(URLFixerUpperTest, FixupFile) {
267 // this "original" filename is the one we tweak to get all the variations
[email protected]b1c33f82009-01-23 01:51:23268 FilePath dir;
269 FilePath original;
initial.commit09911bf2008-07-26 23:55:29270 ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &dir));
[email protected]d3216442009-03-05 21:07:27271 ASSERT_TRUE(MakeTempFile(
272 dir,
273 FilePath(FILE_PATH_LITERAL("url fixer upper existing file.txt")),
274 &original));
initial.commit09911bf2008-07-26 23:55:29275
276 // reference path
[email protected]b1c33f82009-01-23 01:51:23277 std::string golden = net::FilePathToFileURL(original).spec();
initial.commit09911bf2008-07-26 23:55:29278
279 // c:\foo\bar.txt -> file:///c:/foo/bar.txt (basic)
[email protected]b1c33f82009-01-23 01:51:23280#if defined(OS_WIN)
[email protected]d3216442009-03-05 21:07:27281 std::string fixedup = URLFixerUpper::FixupURL(WideToUTF8(original.value()),
282 "");
[email protected]b1c33f82009-01-23 01:51:23283#elif defined(OS_POSIX)
284 std::string fixedup = URLFixerUpper::FixupURL(original.value(), "");
285#endif
initial.commit09911bf2008-07-26 23:55:29286 EXPECT_EQ(golden, fixedup);
287
[email protected]b1c33f82009-01-23 01:51:23288 // TODO(port): Make some equivalent tests for posix.
289#if defined(OS_WIN)
initial.commit09911bf2008-07-26 23:55:29290 // c|/foo\bar.txt -> file:///c:/foo/bar.txt (pipe allowed instead of colon)
[email protected]b1c33f82009-01-23 01:51:23291 std::string cur(WideToUTF8(original.value()));
initial.commit09911bf2008-07-26 23:55:29292 EXPECT_EQ(':', cur[1]);
293 cur[1] = '|';
[email protected]b1c33f82009-01-23 01:51:23294 fixedup = URLFixerUpper::FixupURL(cur, "");
initial.commit09911bf2008-07-26 23:55:29295 EXPECT_EQ(golden, fixedup);
296
297 fixup_case file_cases[] = {
298 // File URLs go through GURL, which tries to escape intelligently.
[email protected]d3216442009-03-05 21:07:27299 {"c:\\This%20is a non-existent file.txt", "",
300 "file:///C:/This%2520is%20a%20non-existent%20file.txt"},
initial.commit09911bf2008-07-26 23:55:29301
302 // \\foo\bar.txt -> file://foo/bar.txt
303 // UNC paths, this file won't exist, but since there are no escapes, it
304 // should be returned just converted to a file: URL.
[email protected]d3216442009-03-05 21:07:27305 {"\\\\SomeNonexistentHost\\foo\\bar.txt", "",
306 "file://somenonexistenthost/foo/bar.txt"},
307 {"//SomeNonexistentHost\\foo/bar.txt", "",
308 "file://somenonexistenthost/foo/bar.txt"},
[email protected]b1c33f82009-01-23 01:51:23309 {"file:///C:/foo/bar", "", "file:///C:/foo/bar"},
initial.commit09911bf2008-07-26 23:55:29310
311 // These are fixups we don't do, but could consider:
312 //
[email protected]b1c33f82009-01-23 01:51:23313 // {"file://C:/foo/bar", "", "file:///C:/foo/bar"},
314 // {"file:c:", "", "file:///c:/"},
315 // {"file:c:WINDOWS", "", "file:///c:/WINDOWS"},
316 // {"file:c|Program Files", "", "file:///c:/Program Files"},
317 // {"file:///foo:/bar", "", "file://foo/bar"},
318 // {"file:/file", "", "file://file/"},
319 // {"file:////////c:\\foo", "", "file:///c:/foo"},
320 // {"file://server/folder/file", "", "file://server/folder/file"},
321 // {"file:/\\/server\\folder/file", "", "file://server/folder/file"},
initial.commit09911bf2008-07-26 23:55:29322 };
[email protected]ba1321d12009-04-21 22:42:29323#elif defined(OS_POSIX)
324 fixup_case file_cases[] = {
325 // File URLs go through GURL, which tries to escape intelligently.
326 {"/This%20is a non-existent file.txt", "",
327 "file:///This%2520is%20a%20non-existent%20file.txt"},
328 // A plain "/" refers to the root.
329 {"/", "",
330 "file:///"},
331 };
332#endif
[email protected]b1c33f82009-01-23 01:51:23333 for (size_t i = 0; i < arraysize(file_cases); i++) {
initial.commit09911bf2008-07-26 23:55:29334 fixedup = URLFixerUpper::FixupURL(file_cases[i].input,
335 file_cases[i].desired_tld);
336 EXPECT_EQ(file_cases[i].output, fixedup);
337 }
338
[email protected]b1c33f82009-01-23 01:51:23339 EXPECT_TRUE(file_util::Delete(original, false));
initial.commit09911bf2008-07-26 23:55:29340}
341
342TEST(URLFixerUpperTest, FixupRelativeFile) {
[email protected]b1c33f82009-01-23 01:51:23343 FilePath full_path, dir;
344 FilePath file_part(FILE_PATH_LITERAL("url_fixer_upper_existing_file.txt"));
initial.commit09911bf2008-07-26 23:55:29345 ASSERT_TRUE(PathService::Get(chrome::DIR_APP, &dir));
346 ASSERT_TRUE(MakeTempFile(dir, file_part, &full_path));
347
348 // make sure we pass through good URLs
[email protected]b1c33f82009-01-23 01:51:23349 std::string fixedup;
350 for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
initial.commit09911bf2008-07-26 23:55:29351 fixup_case value = fixup_cases[i];
[email protected]b1c33f82009-01-23 01:51:23352#if defined(OS_WIN)
353 FilePath input(UTF8ToWide(value.input));
354#elif defined(OS_POSIX)
355 FilePath input(value.input);
356#endif
357 fixedup = URLFixerUpper::FixupRelativeFile(dir, input);
initial.commit09911bf2008-07-26 23:55:29358 EXPECT_EQ(value.output, fixedup);
359 }
360
361 // make sure the existing file got fixed-up to a file URL, and that there
362 // are no backslashes
363 fixedup = URLFixerUpper::FixupRelativeFile(dir, file_part);
[email protected]b1c33f82009-01-23 01:51:23364 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
365 EXPECT_TRUE(file_util::Delete(full_path, false));
initial.commit09911bf2008-07-26 23:55:29366
367 // create a filename we know doesn't exist and make sure it doesn't get
368 // fixed up to a file URL
[email protected]d3216442009-03-05 21:07:27369 FilePath nonexistent_file(
370 FILE_PATH_LITERAL("url_fixer_upper_nonexistent_file.txt"));
initial.commit09911bf2008-07-26 23:55:29371 fixedup = URLFixerUpper::FixupRelativeFile(dir, nonexistent_file);
[email protected]b1c33f82009-01-23 01:51:23372 EXPECT_NE(std::string("file:///"), fixedup.substr(0, 8));
initial.commit09911bf2008-07-26 23:55:29373 EXPECT_FALSE(IsMatchingFileURL(fixedup, nonexistent_file));
374
375 // make a subdir to make sure relative paths with directories work, also
[email protected]d3216442009-03-05 21:07:27376 // test spaces:
377 // "app_dir\url fixer-upper dir\url fixer-upper existing file.txt"
[email protected]b1c33f82009-01-23 01:51:23378 FilePath sub_dir(FILE_PATH_LITERAL("url fixer-upper dir"));
379 FilePath sub_file(FILE_PATH_LITERAL("url fixer-upper existing file.txt"));
380 FilePath new_dir = dir.Append(sub_dir);
381 file_util::CreateDirectory(new_dir);
initial.commit09911bf2008-07-26 23:55:29382 ASSERT_TRUE(MakeTempFile(new_dir, sub_file, &full_path));
383
384 // test file in the subdir
[email protected]b1c33f82009-01-23 01:51:23385 FilePath relative_file = sub_dir.Append(sub_file);
initial.commit09911bf2008-07-26 23:55:29386 fixedup = URLFixerUpper::FixupRelativeFile(dir, relative_file);
[email protected]b1c33f82009-01-23 01:51:23387 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
initial.commit09911bf2008-07-26 23:55:29388
[email protected]b1c33f82009-01-23 01:51:23389 // test file in the subdir with different slashes and escaping.
390 FilePath::StringType relative_file_str = sub_dir.value() +
391 FILE_PATH_LITERAL("/") + sub_file.value();
392 ReplaceSubstringsAfterOffset(&relative_file_str, 0,
393 FILE_PATH_LITERAL(" "), FILE_PATH_LITERAL("%20"));
394 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str));
395 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
initial.commit09911bf2008-07-26 23:55:29396
397 // test relative directories and duplicate slashes
398 // (should resolve to the same file as above)
[email protected]b1c33f82009-01-23 01:51:23399 relative_file_str = sub_dir.value() + FILE_PATH_LITERAL("/../") +
400 sub_dir.value() + FILE_PATH_LITERAL("///./") + sub_file.value();
401 fixedup = URLFixerUpper::FixupRelativeFile(dir, FilePath(relative_file_str));
402 EXPECT_TRUE(IsMatchingFileURL(fixedup, full_path));
initial.commit09911bf2008-07-26 23:55:29403
404 // done with the subdir
[email protected]b1c33f82009-01-23 01:51:23405 EXPECT_TRUE(file_util::Delete(full_path, false));
406 EXPECT_TRUE(file_util::Delete(new_dir, true));
initial.commit09911bf2008-07-26 23:55:29407}