| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 { "http://:b005::68]", "http", | 175 { "http://:b005::68]", "http", |
| 176 url::Component(0, 4), // scheme | 176 url::Component(0, 4), // scheme |
| 177 url::Component(), // username | 177 url::Component(), // username |
| 178 url::Component(), // password | 178 url::Component(), // password |
| 179 url::Component(7, 10), // host | 179 url::Component(7, 10), // host |
| 180 url::Component(), // port | 180 url::Component(), // port |
| 181 url::Component(), // path | 181 url::Component(), // path |
| 182 url::Component(), // query | 182 url::Component(), // query |
| 183 url::Component(), // ref | 183 url::Component(), // ref |
| 184 }, | 184 }, |
| 185 // Can't do anything useful with this. | 185 { ":b005::68]", "http", |
| 186 { ":b005::68]", "", | 186 url::Component(), // scheme |
| 187 url::Component(0, 0), // scheme | |
| 188 url::Component(), // username | 187 url::Component(), // username |
| 189 url::Component(), // password | 188 url::Component(), // password |
| 190 url::Component(), // host | 189 url::Component(1, 9), // host |
| 191 url::Component(), // port | 190 url::Component(), // port |
| 192 url::Component(), // path | 191 url::Component(), // path |
| 193 url::Component(), // query | 192 url::Component(), // query |
| 194 url::Component(), // ref | 193 url::Component(), // ref |
| 195 }, | 194 }, |
| 196 }; | 195 }; |
| 197 | 196 |
| 198 typedef testing::Test URLFixerTest; | 197 typedef testing::Test URLFixerTest; |
| 199 | 198 |
| 200 TEST(URLFixerTest, SegmentURL) { | 199 TEST(URLFixerTest, SegmentURL) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 {"http://foo.com/s?q=\xf0\x90\x80\x85", "http://foo.com/s?q=%F0%90%80%85"}, | 289 {"http://foo.com/s?q=\xf0\x90\x80\x85", "http://foo.com/s?q=%F0%90%80%85"}, |
| 291 // URLs which end with 0xA0 (non-break space in ISO-8859). | 290 // URLs which end with 0xA0 (non-break space in ISO-8859). |
| 292 {"http://foo.com/s?q=\xd0\xa0", "http://foo.com/s?q=%D0%A0"}, | 291 {"http://foo.com/s?q=\xd0\xa0", "http://foo.com/s?q=%D0%A0"}, |
| 293 {"http://foo.com/s?q=\xec\x97\xa0", "http://foo.com/s?q=%EC%97%A0"}, | 292 {"http://foo.com/s?q=\xec\x97\xa0", "http://foo.com/s?q=%EC%97%A0"}, |
| 294 {"http://foo.com/s?q=\xf0\x90\x80\xa0", "http://foo.com/s?q=%F0%90%80%A0"}, | 293 {"http://foo.com/s?q=\xf0\x90\x80\xa0", "http://foo.com/s?q=%F0%90%80%A0"}, |
| 295 // URLs containing IPv6 literals. | 294 // URLs containing IPv6 literals. |
| 296 {"[2001:db8::2]", "http://[2001:db8::2]/"}, | 295 {"[2001:db8::2]", "http://[2001:db8::2]/"}, |
| 297 {"[::]:80", "http://[::]/"}, | 296 {"[::]:80", "http://[::]/"}, |
| 298 {"[::]:80/path", "http://[::]/path"}, | 297 {"[::]:80/path", "http://[::]/path"}, |
| 299 {"[::]:180/path", "http://[::]:180/path"}, | 298 {"[::]:180/path", "http://[::]:180/path"}, |
| 300 // TODO(pmarks): Maybe we should parse bare IPv6 literals someday. | 299 // TODO(pmarks): Maybe we should parse bare IPv6 literals someday. Currently |
| 301 {"::1", "::1"}, | 300 // the first colon is treated as a scheme separator, and we default |
| 301 // unspecified schemes to "http". |
| 302 {"::1", "http://:1/"}, |
| 302 // Semicolon as scheme separator for standard schemes. | 303 // Semicolon as scheme separator for standard schemes. |
| 303 {"http;//www.google.com/", "http://www.google.com/"}, | 304 {"http;//www.google.com/", "http://www.google.com/"}, |
| 304 {"about;chrome", "chrome://chrome/"}, | 305 {"about;chrome", "chrome://chrome/"}, |
| 305 // Semicolon in non-standard schemes is not replaced by colon. | 306 // Semicolon in non-standard schemes is not replaced by colon. |
| 306 {"whatsup;//fool", "http://whatsup%3B//fool"}, | 307 {"whatsup;//fool", "http://whatsup%3B//fool"}, |
| 307 // Semicolon left as-is in URL itself. | 308 // Semicolon left as-is in URL itself. |
| 308 {"http://host/port?query;moar", "http://host/port?query;moar"}, | 309 {"http://host/port?query;moar", "http://host/port?query;moar"}, |
| 309 // Fewer slashes than expected. | 310 // Fewer slashes than expected. |
| 310 {"http;www.google.com/", "http://www.google.com/"}, | 311 {"http;www.google.com/", "http://www.google.com/"}, |
| 311 {"http;/www.google.com/", "http://www.google.com/"}, | 312 {"http;/www.google.com/", "http://www.google.com/"}, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 EXPECT_TRUE(base::DeleteFile(full_path, false)); | 536 EXPECT_TRUE(base::DeleteFile(full_path, false)); |
| 536 EXPECT_TRUE(base::DeleteFile(new_dir, true)); | 537 EXPECT_TRUE(base::DeleteFile(new_dir, true)); |
| 537 | 538 |
| 538 // Test that an obvious HTTP URL isn't accidentally treated as an absolute | 539 // Test that an obvious HTTP URL isn't accidentally treated as an absolute |
| 539 // file path (on account of system-specific craziness). | 540 // file path (on account of system-specific craziness). |
| 540 base::FilePath empty_path; | 541 base::FilePath empty_path; |
| 541 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../")); | 542 base::FilePath http_url_path(FILE_PATH_LITERAL("http://../")); |
| 542 EXPECT_TRUE(url_formatter::FixupRelativeFile(empty_path, http_url_path) | 543 EXPECT_TRUE(url_formatter::FixupRelativeFile(empty_path, http_url_path) |
| 543 .SchemeIs("http")); | 544 .SchemeIs("http")); |
| 544 } | 545 } |
| OLD | NEW |