OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "net/base/filename_util.h" | 5 #include "net/base/filename_util.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 L"", | 587 L"", |
588 L"caf\u00e9.png"}, | 588 L"caf\u00e9.png"}, |
589 {__LINE__, | 589 {__LINE__, |
590 "http://www.example.com/images?id=3", | 590 "http://www.example.com/images?id=3", |
591 "attachment; filename=caf\xe5.png", | 591 "attachment; filename=caf\xe5.png", |
592 "windows-1253", | 592 "windows-1253", |
593 "", | 593 "", |
594 "", | 594 "", |
595 L"", | 595 L"", |
596 L"caf\u03b5.png"}, | 596 L"caf\u03b5.png"}, |
597 {__LINE__, | 597 {// Invalid C-D header. Name value is skipped now. |
| 598 __LINE__, |
598 "http://www.example.com/file?id=3", | 599 "http://www.example.com/file?id=3", |
599 "attachment; name=\xcf\xc2\xd4\xd8.zip", | 600 "attachment; name=\xcf\xc2\xd4\xd8.zip", |
600 "GBK", | 601 "GBK", |
601 "", | 602 "", |
602 "", | 603 "", |
603 L"", | 604 L"", |
604 L"\u4e0b\u8f7d.zip"}, | 605 L"file"}, |
605 {// Invalid C-D header. Extracts filename from url. | 606 {// Invalid C-D header. Extracts filename from url. |
606 __LINE__, | 607 __LINE__, |
607 "http://www.google.com/test.html", | 608 "http://www.google.com/test.html", |
608 "attachment; filename==?iiso88591?Q?caf=EG?=", | 609 "attachment; filename==?iiso88591?Q?caf=EG?=", |
609 "", | 610 "", |
610 "", | 611 "", |
611 "", | 612 "", |
612 L"", | 613 L"", |
613 L"test.html"}, | 614 L"test.html"}, |
614 // about: and data: URLs | 615 // about: and data: URLs |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 {// % encoded | 726 {// % encoded |
726 __LINE__, | 727 __LINE__, |
727 "http://www.examples.com/", | 728 "http://www.examples.com/", |
728 "attachment; " | 729 "attachment; " |
729 "filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"", | 730 "filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"", |
730 "", | 731 "", |
731 "", | 732 "", |
732 "image/jpeg", | 733 "image/jpeg", |
733 L"download", | 734 L"download", |
734 L"\uc608\uc220 \uc608\uc220.jpg"}, | 735 L"\uc608\uc220 \uc608\uc220.jpg"}, |
735 {// name= parameter | 736 {// Invalid C-D header. Name value is skipped now. |
736 __LINE__, | 737 __LINE__, |
737 "http://www.examples.com/q.cgi?id=abc", | 738 "http://www.examples.com/q.cgi?id=abc", |
738 "attachment; name=abc de.pdf", | 739 "attachment; name=abc de.pdf", |
739 "", | 740 "", |
740 "", | 741 "", |
741 "application/octet-stream", | 742 "application/octet-stream", |
742 L"download", | 743 L"download", |
743 L"abc de.pdf"}, | 744 L"q.cgi"}, |
744 {__LINE__, | 745 {__LINE__, |
745 "http://www.example.com/path", | 746 "http://www.example.com/path", |
746 "filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"", | 747 "filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"", |
747 "", | 748 "", |
748 "", | 749 "", |
749 "image/png", | 750 "image/png", |
750 L"download", | 751 L"download", |
751 L"\x82b8\x8853" | 752 L"\x82b8\x8853" |
752 L"3.png"}, | 753 L"3.png"}, |
753 {// The following two have invalid CD headers and filenames come from the | 754 {// The following two have invalid CD headers and filenames come from the |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 RunGenerateFileNameTestCase(&generation_tests[i]); | 1403 RunGenerateFileNameTestCase(&generation_tests[i]); |
1403 | 1404 |
1404 for (size_t i = 0; i < arraysize(generation_tests); ++i) { | 1405 for (size_t i = 0; i < arraysize(generation_tests); ++i) { |
1405 GenerateFilenameCase test_case = generation_tests[i]; | 1406 GenerateFilenameCase test_case = generation_tests[i]; |
1406 test_case.referrer_charset = "GBK"; | 1407 test_case.referrer_charset = "GBK"; |
1407 RunGenerateFileNameTestCase(&test_case); | 1408 RunGenerateFileNameTestCase(&test_case); |
1408 } | 1409 } |
1409 } | 1410 } |
1410 | 1411 |
1411 } // namespace net | 1412 } // namespace net |
OLD | NEW |