Lines Matching +full:download +full:- +full:url
2 // Use of this source code is governed by a BSD-style license that can be
16 #include "url/gurl.h"
24 const char* url; member
29 const char* url; member
61 // LC_CTYPE is not "utf8" or "utf-8" because some of the string conversions in GetLocaleWarningString()
76 std::string default_filename(base::WideToUTF8(test_case->default_filename)); in RunGenerateFileNameTestCase()
78 GURL(test_case->url), test_case->content_disp_header, in RunGenerateFileNameTestCase()
79 test_case->referrer_charset, test_case->suggested_filename, in RunGenerateFileNameTestCase()
80 test_case->mime_type, default_filename); in RunGenerateFileNameTestCase()
81 EXPECT_EQ(test_case->expected_filename, FilePathAsWString(file_path)) in RunGenerateFileNameTestCase()
82 << "test case at line number: " << test_case->lineno << "; " in RunGenerateFileNameTestCase()
88 FILE_PATH_LITERAL("a b.txt"), FILE_PATH_LITERAL("a-b.txt"),
113 FILE_PATH_LITERAL("My Computer.{20D04FE0-3AEA-1069-A2D8-08002B30309D}"),
193 // Other percent-encoded characters that are left alone when displaying a in TEST()
194 // URL are decoded in a file path (https://crbug.com/585422). in TEST()
217 // Other percent-encoded characters that are left alone when displaying a in TEST()
218 // URL are decoded in a file path (https://crbug.com/585422). in TEST()
224 // First, we'll test that we can round-trip all of the above cases of URLs in TEST()
227 // convert to the file URL in TEST()
229 EXPECT_EQ(test_case.url, file_url.spec()); in TEST()
258 // Other percent-encoded characters that are left alone when displaying a in TEST()
259 // URL are decoded in a file path (https://crbug.com/585422). in TEST()
285 // Other percent-encoded characters that are left alone when displaying a in TEST()
286 // URL are decoded in a file path (https://crbug.com/585422). in TEST()
291 // Backslashes in a file URL are normalized as forward slashes. in TEST()
295 // Accept obviously-local file URLs. in TEST()
300 // Reject non-local file URLs. in TEST()
309 FileURLToFilePath(GURL(test_case.url), &output)); in TEST()
317 // Invalid UTF-8 tests can't be tested above because FilePathAsWString assumes in TEST()
318 // the output is valid UTF-8. in TEST()
320 // Invalid UTF-8 bytes in input. in TEST()
325 // On Windows, invalid UTF-8 bytes are interpreted using the default ANSI in TEST()
326 // code page. This defaults to Windows-1252 (which we assume here). in TEST()
331 // No conversion should happen, and the invalid UTF-8 should be preserved. in TEST()
337 // Invalid UTF-8 percent-encoded bytes in input. in TEST()
342 // On Windows, invalid UTF-8 bytes are interpreted using the default ANSI in TEST()
343 // code page. This defaults to Windows-1252 (which we assume here). in TEST()
348 // No conversion should happen, and the invalid UTF-8 should be preserved. in TEST()
354 // Test that if a file URL is malformed, we get a failure in TEST()
367 {__LINE__, "application/x-chrome-extension", "bar", "bar.crx"}, in TEST()
380 {__LINE__, "application/x-chrome-extension", "con", "_con.crx"}, in TEST()
383 {__LINE__, "text/html", "harmless.{not-really-this-may-be-a-guid}", in TEST()
384 "harmless.download"}, in TEST()
385 {__LINE__, "text/html", "harmless.{mismatched-", "harmless.{mismatched-"}, in TEST()
388 {__LINE__, "text/html", "harmless.local", "harmless.download"}, in TEST()
389 {__LINE__, "text/html", "harmless.lnk", "harmless.download"}, in TEST()
394 {__LINE__, "application/x-chrome-extension", "con", "con.crx"}, in TEST()
395 {__LINE__, "text/html", "harmless.{not-really-this-may-be-a-guid}", in TEST()
396 "harmless.{not-really-this-may-be-a-guid}"}, in TEST()
397 {__LINE__, "text/html", "harmless.{mismatched-", "harmless.{mismatched-"}, in TEST()
421 EXPECT_TRUE(GetPreferredExtensionForMimeType("application/x-chrome-extension", in TEST()
428 // parameters and that Content-Disposition headers are properly in TEST()
431 {// Picks the filename from the C-D header. in TEST()
434 {// Ditto. The C-D header uses a quoted string. in TEST()
444 {// Filename is whitespace. Should failover to URL host in TEST()
453 {// No C-D, and no URL path. in TEST()
456 {// No C-D. URL has a path. in TEST()
459 {// No C-D. URL's path ends in a slash which results in an empty final in TEST()
463 {// No C-D. URL has a path, but the path has no extension. in TEST()
465 {// No C-D. URL gives no filename hints. in TEST()
466 __LINE__, "file:///", "", "", "", "", L"", L"download"}, in TEST()
467 {// file:// URL. in TEST()
470 __LINE__, "non-standard-scheme:", "", "", "", "", L"", L"download"}, in TEST()
471 {// C-D overrides default in TEST()
473 "attachment; filename =\"test.html\"", "", "", "", L"download", in TEST()
475 {// But the URL doesn't in TEST()
476 __LINE__, "http://www.google.com/", "", "", "", "", L"download", in TEST()
477 L"download"}, in TEST()
486 "", "", "", L"download", L"\uc608\uc220 \uc608\uc220.jpg"}, in TEST()
490 "attachment; filename=\"=?EUC-JP?Q?=B7=DD=BD=" in TEST()
492 "", "", "", L"download", L"\u82b8\u88533.png"}, in TEST()
494 "attachment; filename=caf\xc3\xa9.png", "iso-8859-1", "", "", L"", in TEST()
497 "attachment; filename=caf\xe5.png", "windows-1253", "", "", L"", in TEST()
499 {// Invalid C-D header. Name value is skipped now. in TEST()
502 {// Invalid C-D header. Extracts filename from url. in TEST()
507 {__LINE__, "about:chrome", "", "", "", "", L"", L"download"}, in TEST()
508 {__LINE__, "data:,looks/like/a.path", "", "", "", "", L"", L"download"}, in TEST()
510 "", "", L"", L"download"}, in TEST()
518 "iso-8859-1", "", "", L"", L"V\u00fdvojov\u00e1 psychologie.doc"}, in TEST()
519 {// Suggested filename takes precedence over URL in TEST()
522 {// The content-disposition has higher precedence over the suggested name. in TEST()
526 "utf-8", "", "image/png", L"", L"test"}, in TEST()
527 // Raw 8bit characters in C-D in TEST()
529 "attachment; filename=caf\xc3\xa9.png", "iso-8859-1", "", "image/png", in TEST()
532 "attachment; filename=caf\xe5.png", "windows-1253", "", "image/png", L"", in TEST()
534 {// No 'filename' keyword in the disposition, use the URL in TEST()
536 "", "text/plain", L"download", L"my_download.txt"}, in TEST()
539 "filename=My Downloaded File.exe", "", "", "application/octet-stream", in TEST()
540 L"download", L"My Downloaded File.exe"}, in TEST()
545 "", "", "application/x-chrome-extension", L"download", in TEST()
547 {// Invalid C-D header. Name value is skipped now. in TEST()
549 "attachment; name=abc de.pdf", "", "", "application/octet-stream", in TEST()
550 L"download", L"q.cgi"}, in TEST()
552 "filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"", "", "", "image/png", in TEST()
553 L"download", in TEST()
557 // URL. in TEST()
559 "attachment; filename==?iiso88591?Q?caf=EG?=", "", "", "", L"download", in TEST()
563 "malformed_disposition", "", "", "", L"download", in TEST()
565 {// Invalid C-D. No filename from URL. Falls back to 'download'. in TEST()
567 "attachment; filename==?iso88591?Q?caf=E3?", "", "", "", L"download", in TEST()
568 L"download"}, in TEST()
582 "text/plain", L"download", L"_.._.._.._._._.._a_file_name.txt"}, in TEST()
585 L"download", L"dir1_dir2_a_file_name.txt"}, in TEST()
588 "text/plain", L"download", L"_.._.._.._._._.._a_file_name.txt"}, in TEST()
591 L"download", L"dir1_dir2_a_file_name.txt"}, in TEST()
596 __LINE__, "https://example.com/misc/2.avi", "", "", "", "video/x-msvideo", in TEST()
597 L"download", L"2.avi"}, in TEST()
600 "text/plain", L"download", L"foo_.._bar.jpg"}, in TEST()
602 // with an underscore. (Note: This can't be tested with a URL, since "%00" in TEST()
603 // is illegal in a URL. Only applies to Content-Disposition.) in TEST()
604 __LINE__, "http://example.com/download.py", "filename=foo%00bar.jpg", "", in TEST()
605 "", "text/plain", L"download", L"foo_bar.jpg"}, in TEST()
606 {// Extension generation for C-D derived filenames. in TEST()
607 __LINE__, "", "filename=my-cat", "", "", "image/jpeg", L"download", in TEST()
608 L"my-cat"}, in TEST()
610 __LINE__, "", "filename=my-cat", "", "", "dance/party", L"download", in TEST()
611 L"my-cat"}, in TEST()
613 __LINE__, "", "filename=my-cat.jpg", "", "", "text/plain", L"download", in TEST()
614 L"my-cat.jpg"}, in TEST()
617 {__LINE__, "", "filename=evil.exe ", "", "", "binary/octet-stream", in TEST()
618 L"download", L"evil.exe"}, in TEST()
619 {__LINE__, "", "filename=evil.exe.", "", "", "binary/octet-stream", in TEST()
620 L"download", L"evil.exe_"}, in TEST()
621 {__LINE__, "", "filename=evil.exe. . .", "", "", "binary/octet-stream", in TEST()
622 L"download", L"evil.exe_______"}, in TEST()
623 {__LINE__, "", "filename=evil.", "", "", "binary/octet-stream", L"download", in TEST()
625 {__LINE__, "", "filename=. . . . .", "", "", "binary/octet-stream", in TEST()
626 L"download", L"download"}, in TEST()
628 // Test truncation of trailing dots and spaces (non-Windows) in TEST()
629 {__LINE__, "", "filename=evil.exe ", "", "", "binary/octet-stream", in TEST()
630 L"download", L"evil.exe"}, in TEST()
631 {__LINE__, "", "filename=evil.exe.", "", "", "binary/octet-stream", in TEST()
632 L"download", L"evil.exe"}, in TEST()
633 {__LINE__, "", "filename=evil.exe. . .", "", "", "binary/octet-stream", in TEST()
634 L"download", L"evil.exe. . _"}, in TEST()
635 {__LINE__, "", "filename=evil.", "", "", "binary/octet-stream", L"download", in TEST()
637 {__LINE__, "", "filename=. . . . .", "", "", "binary/octet-stream", in TEST()
638 L"download", L"_. . ._"}, in TEST()
641 "binary/octet-stream", L"", L"meh.exe_"}, in TEST()
643 {__LINE__, "", "filename=.", "", "", "dance/party", L"download", in TEST()
644 L"download"}, in TEST()
645 {__LINE__, "", "filename=..", "", "", "dance/party", L"download", in TEST()
646 L"download"}, in TEST()
647 {__LINE__, "", "filename=...", "", "", "dance/party", L"download", in TEST()
648 L"download"}, in TEST()
650 {__LINE__, "", "filename=COM1", "", "", "application/foo-bar", L"download", in TEST()
657 {__LINE__, "", "filename=COM4.txt", "", "", "text/plain", L"download", in TEST()
664 {__LINE__, "", "filename=lpt1.TXT", "", "", "text/plain", L"download", in TEST()
671 {__LINE__, "", "filename=clock$.txt", "", "", "text/plain", L"download", in TEST()
679 __LINE__, "", "", "", "clock$.txt", "text/plain", L"download", in TEST()
687 __LINE__, "", "filename=mycom1.foo", "", "", "", L"download", in TEST()
689 {__LINE__, "", "filename=Setup.exe.local", "", "", "", L"download", in TEST()
691 L"Setup.exe.download" in TEST()
696 {__LINE__, "", "filename=Setup.exe.local.local", "", "", "", L"download", in TEST()
698 L"Setup.exe.local.download" in TEST()
703 {__LINE__, "", "filename=Setup.exe.lnk", "", "", "", L"download", in TEST()
705 L"Setup.exe.download" in TEST()
710 {__LINE__, "", "filename=Desktop.ini", "", "", "", L"download", in TEST()
717 {__LINE__, "", "filename=Thumbs.db", "", "", "", L"download", in TEST()
728 "application/x-tar", L"download", L"foo.tar.gz"}, in TEST()
731 "application/x-tar", L"download", L"foo.tgz"}, in TEST()
734 "text/x-registry", L"download", L"blank.reg"}, in TEST()
736 "application/x-tar", L"download", L"bar.tar"}, in TEST()
738 "application/x-tar", L"download", L"bar.bogus"}, in TEST()
740 __LINE__, "http://www.example.com/.download.txt", "filename=.download.txt", in TEST()
741 "", "", "text/plain", L"-download", L"download.txt"}, in TEST()
743 __LINE__, "http://www.example.com/bar.sh", "", "", "", "application/x-sh", in TEST()
744 L"download", L"bar.sh"}, in TEST()
747 "application/x-chrome-extension", L"download", L"npdf.crx"}, in TEST()
748 {// Shouldn't overwrite C-D specified extension. in TEST()
750 "filename=foobar.jpg", "", "", "text/plain", L"download", L"foobar.jpg"}, in TEST()
753 "application/x-chrome-extension", L"download", L"image.crx"}, in TEST()
755 "", L"download", L"_.foo"}, in TEST()
758 // They only fail if application/[x-]gzip has a default extension, which in TEST()
763 "", "application/x-gzip", L"", L"goat.tar.gz"}, in TEST()
767 "application/x-gzip", L"", L"goat.tgz"}, in TEST()
775 // U+3000 IDEOGRAPHIC SPACE (http://crbug.com/849794): In URL file name. in TEST()
779 // Content-Disposition filename. in TEST()
780 {__LINE__, "http://www.example.com/download.py", in TEST()
781 "filename=%E5%B2%A1%E3%80%80%E5%B2%A1.txt", "utf-8", "", "text/plain", L"", in TEST()