Commit 407b3437 authored by Asanka Herath's avatar Asanka Herath Committed by Commit Bot

clang-format net/base/filename_util_unittest.cc

Hopefully this will make the upcoming CLs more readable.

Bug: None
Change-Id: I2ca162b4ca7f8bed48646a02602e62fb86d75f11
Reviewed-on: https://chromium-review.googlesource.com/990993Reviewed-by: default avatarBence Béky <bnc@chromium.org>
Commit-Queue: Asanka Herath <asanka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547690}
parent 4ec1a937
...@@ -300,87 +300,62 @@ TEST(FilenameUtilTest, GenerateSafeFileName) { ...@@ -300,87 +300,62 @@ TEST(FilenameUtilTest, GenerateSafeFileName) {
const base::FilePath::CharType* expected_filename; const base::FilePath::CharType* expected_filename;
} safe_tests[] = { } safe_tests[] = {
#if defined(OS_WIN) #if defined(OS_WIN)
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\bar.htm"),
FILE_PATH_LITERAL("C:\\foo\\bar.htm"),
FILE_PATH_LITERAL("C:\\foo\\bar.htm")}, FILE_PATH_LITERAL("C:\\foo\\bar.htm")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\bar.html"),
FILE_PATH_LITERAL("C:\\foo\\bar.html"),
FILE_PATH_LITERAL("C:\\foo\\bar.html")}, FILE_PATH_LITERAL("C:\\foo\\bar.html")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\bar"),
FILE_PATH_LITERAL("C:\\foo\\bar"),
FILE_PATH_LITERAL("C:\\foo\\bar.htm")}, FILE_PATH_LITERAL("C:\\foo\\bar.htm")},
{"image/png", {"image/png", FILE_PATH_LITERAL("C:\\bar.html"),
FILE_PATH_LITERAL("C:\\bar.html"),
FILE_PATH_LITERAL("C:\\bar.html")}, FILE_PATH_LITERAL("C:\\bar.html")},
{"image/png", {"image/png", FILE_PATH_LITERAL("C:\\bar"),
FILE_PATH_LITERAL("C:\\bar"),
FILE_PATH_LITERAL("C:\\bar.png")}, FILE_PATH_LITERAL("C:\\bar.png")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
FILE_PATH_LITERAL("C:\\foo\\bar.exe")}, FILE_PATH_LITERAL("C:\\foo\\bar.exe")},
{"image/gif", {"image/gif", FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
FILE_PATH_LITERAL("C:\\foo\\bar.exe"),
FILE_PATH_LITERAL("C:\\foo\\bar.exe")}, FILE_PATH_LITERAL("C:\\foo\\bar.exe")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\google.com"),
FILE_PATH_LITERAL("C:\\foo\\google.com"),
FILE_PATH_LITERAL("C:\\foo\\google.com")}, FILE_PATH_LITERAL("C:\\foo\\google.com")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\con.htm"),
FILE_PATH_LITERAL("C:\\foo\\con.htm"),
FILE_PATH_LITERAL("C:\\foo\\_con.htm")}, FILE_PATH_LITERAL("C:\\foo\\_con.htm")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\con"),
FILE_PATH_LITERAL("C:\\foo\\con"),
FILE_PATH_LITERAL("C:\\foo\\_con.htm")}, FILE_PATH_LITERAL("C:\\foo\\_con.htm")},
{"text/html", {"text/html",
FILE_PATH_LITERAL("C:\\foo\\harmless.{not-really-this-may-be-a-guid}"), FILE_PATH_LITERAL("C:\\foo\\harmless.{not-really-this-may-be-a-guid}"),
FILE_PATH_LITERAL("C:\\foo\\harmless.download")}, FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\harmless.local"),
FILE_PATH_LITERAL("C:\\foo\\harmless.local"),
FILE_PATH_LITERAL("C:\\foo\\harmless.download")}, FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\harmless.lnk"),
FILE_PATH_LITERAL("C:\\foo\\harmless.lnk"),
FILE_PATH_LITERAL("C:\\foo\\harmless.download")}, FILE_PATH_LITERAL("C:\\foo\\harmless.download")},
{"text/html", {"text/html", FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-"),
FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-"),
FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-")}, FILE_PATH_LITERAL("C:\\foo\\harmless.{mismatched-")},
// Allow extension synonyms. // Allow extension synonyms.
{"image/jpeg", {"image/jpeg", FILE_PATH_LITERAL("C:\\foo\\bar.jpg"),
FILE_PATH_LITERAL("C:\\foo\\bar.jpg"),
FILE_PATH_LITERAL("C:\\foo\\bar.jpg")}, FILE_PATH_LITERAL("C:\\foo\\bar.jpg")},
{"image/jpeg", {"image/jpeg", FILE_PATH_LITERAL("C:\\foo\\bar.jpeg"),
FILE_PATH_LITERAL("C:\\foo\\bar.jpeg"),
FILE_PATH_LITERAL("C:\\foo\\bar.jpeg")}, FILE_PATH_LITERAL("C:\\foo\\bar.jpeg")},
#else // !defined(OS_WIN) #else // !defined(OS_WIN)
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/bar.htm"),
FILE_PATH_LITERAL("/foo/bar.htm"),
FILE_PATH_LITERAL("/foo/bar.htm")}, FILE_PATH_LITERAL("/foo/bar.htm")},
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/bar.html"),
FILE_PATH_LITERAL("/foo/bar.html"),
FILE_PATH_LITERAL("/foo/bar.html")}, FILE_PATH_LITERAL("/foo/bar.html")},
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/bar"),
FILE_PATH_LITERAL("/foo/bar"),
FILE_PATH_LITERAL("/foo/bar.html")}, FILE_PATH_LITERAL("/foo/bar.html")},
{"image/png", {"image/png", FILE_PATH_LITERAL("/bar.html"),
FILE_PATH_LITERAL("/bar.html"),
FILE_PATH_LITERAL("/bar.html")}, FILE_PATH_LITERAL("/bar.html")},
{"image/png", FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("/bar.png")}, {"image/png", FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("/bar.png")},
{"image/gif", {"image/gif", FILE_PATH_LITERAL("/foo/bar.exe"),
FILE_PATH_LITERAL("/foo/bar.exe"),
FILE_PATH_LITERAL("/foo/bar.exe")}, FILE_PATH_LITERAL("/foo/bar.exe")},
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/google.com"),
FILE_PATH_LITERAL("/foo/google.com"),
FILE_PATH_LITERAL("/foo/google.com")}, FILE_PATH_LITERAL("/foo/google.com")},
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/con.htm"),
FILE_PATH_LITERAL("/foo/con.htm"),
FILE_PATH_LITERAL("/foo/con.htm")}, FILE_PATH_LITERAL("/foo/con.htm")},
{"text/html", {"text/html", FILE_PATH_LITERAL("/foo/con"),
FILE_PATH_LITERAL("/foo/con"),
FILE_PATH_LITERAL("/foo/con.html")}, FILE_PATH_LITERAL("/foo/con.html")},
// Allow extension synonyms. // Allow extension synonyms.
{"image/jpeg", {"image/jpeg", FILE_PATH_LITERAL("/bar.jpg"),
FILE_PATH_LITERAL("/bar.jpg"),
FILE_PATH_LITERAL("/bar.jpg")}, FILE_PATH_LITERAL("/bar.jpg")},
{"image/jpeg", {"image/jpeg", FILE_PATH_LITERAL("/bar.jpeg"),
FILE_PATH_LITERAL("/bar.jpeg"),
FILE_PATH_LITERAL("/bar.jpeg")}, FILE_PATH_LITERAL("/bar.jpeg")},
#endif // !defined(OS_WIN) #endif // !defined(OS_WIN)
}; };
...@@ -398,288 +373,104 @@ TEST(FilenameUtilTest, GenerateFileName) { ...@@ -398,288 +373,104 @@ TEST(FilenameUtilTest, GenerateFileName) {
// parameters and that Content-Disposition headers are properly // parameters and that Content-Disposition headers are properly
// handled including failovers when the header is malformed. // handled including failovers when the header is malformed.
const GenerateFilenameCase selection_tests[] = { const GenerateFilenameCase selection_tests[] = {
{__LINE__, {__LINE__, "http://www.google.com/", "attachment; filename=test.html", "",
"http://www.google.com/", "", "", L"", L"test.html"},
"attachment; filename=test.html", {__LINE__, "http://www.google.com/", "attachment; filename=\"test.html\"",
"", "", "", "", L"", L"test.html"},
"", {__LINE__, "http://www.google.com/", "attachment; filename= \"test.html\"",
"", "", "", "", L"", L"test.html"},
L"", {__LINE__, "http://www.google.com/",
L"test.html"}, "attachment; filename = \"test.html\"", "", "", "", L"", L"test.html"},
{__LINE__,
"http://www.google.com/",
"attachment; filename=\"test.html\"",
"",
"",
"",
L"",
L"test.html"},
{__LINE__,
"http://www.google.com/",
"attachment; filename= \"test.html\"",
"",
"",
"",
L"",
L"test.html"},
{__LINE__,
"http://www.google.com/",
"attachment; filename = \"test.html\"",
"",
"",
"",
L"",
L"test.html"},
{// filename is whitespace. Should failover to URL host {// filename is whitespace. Should failover to URL host
__LINE__, __LINE__, "http://www.google.com/", "attachment; filename= ", "", "", "",
"http://www.google.com/", L"", L"www.google.com"},
"attachment; filename= ",
"",
"",
"",
L"",
L"www.google.com"},
{// No filename. {// No filename.
__LINE__, __LINE__, "http://www.google.com/path/test.html", "attachment", "", "", "",
"http://www.google.com/path/test.html", L"", L"test.html"},
"attachment",
"",
"",
"",
L"",
L"test.html"},
{// Ditto {// Ditto
__LINE__, __LINE__, "http://www.google.com/path/test.html", "attachment;", "", "",
"http://www.google.com/path/test.html", "", L"", L"test.html"},
"attachment;",
"",
"",
"",
L"",
L"test.html"},
{// No C-D {// No C-D
__LINE__, __LINE__, "http://www.google.com/", "", "", "", "", L"",
"http://www.google.com/",
"",
"",
"",
"",
L"",
L"www.google.com"}, L"www.google.com"},
{__LINE__, {__LINE__, "http://www.google.com/test.html", "", "", "", "", L"",
"http://www.google.com/test.html",
"",
"",
"",
"",
L"",
L"test.html"}, L"test.html"},
{// Now that we use src/url's ExtractFileName, this case falls back to {// Now that we use src/url's ExtractFileName, this case falls back to
// the hostname. If this behavior is not desirable, we'd better change // the hostname. If this behavior is not desirable, we'd better change
// ExtractFileName (in url_parse.cc). // ExtractFileName (in url_parse.cc).
__LINE__, __LINE__, "http://www.google.com/path/", "", "", "", "", L"",
"http://www.google.com/path/",
"",
"",
"",
"",
L"",
L"www.google.com"}, L"www.google.com"},
{__LINE__, "http://www.google.com/path", "", "", "", "", L"", L"path"}, {__LINE__, "http://www.google.com/path", "", "", "", "", L"", L"path"},
{__LINE__, "file:///", "", "", "", "", L"", L"download"}, {__LINE__, "file:///", "", "", "", "", L"", L"download"},
{__LINE__, "file:///path/testfile", "", "", "", "", L"", L"testfile"}, {__LINE__, "file:///path/testfile", "", "", "", "", L"", L"testfile"},
{__LINE__, "non-standard-scheme:", "", "", "", "", L"", L"download"}, {__LINE__, "non-standard-scheme:", "", "", "", "", L"", L"download"},
{// C-D should override default {// C-D should override default
__LINE__, __LINE__, "http://www.google.com/", "attachment; filename =\"test.html\"",
"http://www.google.com/", "", "", "", L"download", L"test.html"},
"attachment; filename =\"test.html\"",
"",
"",
"",
L"download",
L"test.html"},
{// But the URL shouldn't {// But the URL shouldn't
__LINE__, __LINE__, "http://www.google.com/", "", "", "", "", L"download",
"http://www.google.com/",
"",
"",
"",
"",
L"download",
L"download"}, L"download"},
{__LINE__, {__LINE__, "http://www.google.com/",
"http://www.google.com/", "attachment; filename=\"../test.html\"", "", "", "", L"", L"_test.html"},
"attachment; filename=\"../test.html\"", {__LINE__, "http://www.google.com/",
"", "attachment; filename=\"..\\test.html\"", "", "", "", L"", L"test.html"},
"", {__LINE__, "http://www.google.com/",
"", "attachment; filename=\"..\\\\test.html\"", "", "", "", L"",
L"",
L"_test.html"},
{__LINE__,
"http://www.google.com/",
"attachment; filename=\"..\\test.html\"",
"",
"",
"",
L"",
L"test.html"},
{__LINE__,
"http://www.google.com/",
"attachment; filename=\"..\\\\test.html\"",
"",
"",
"",
L"",
L"_test.html"}, L"_test.html"},
{// Filename disappears after leading and trailing periods are removed. {// Filename disappears after leading and trailing periods are removed.
__LINE__, __LINE__, "http://www.google.com/", "attachment; filename=\"..\"", "", "",
"http://www.google.com/", "", L"default", L"default"},
"attachment; filename=\"..\"",
"",
"",
"",
L"default",
L"default"},
{// C-D specified filename disappears. Failover to final filename. {// C-D specified filename disappears. Failover to final filename.
__LINE__, __LINE__, "http://www.google.com/test.html", "attachment; filename=\"..\"",
"http://www.google.com/test.html", "", "", "", L"default", L"default"},
"attachment; filename=\"..\"",
"",
"",
"",
L"default",
L"default"},
// Below is a small subset of cases taken from HttpContentDisposition tests. // Below is a small subset of cases taken from HttpContentDisposition tests.
{__LINE__, {__LINE__, "http://www.google.com/",
"http://www.google.com/",
"attachment; filename=\"%EC%98%88%EC%88%A0%20" "attachment; filename=\"%EC%98%88%EC%88%A0%20"
"%EC%98%88%EC%88%A0.jpg\"", "%EC%98%88%EC%88%A0.jpg\"",
"", "", "", "", L"", L"\uc608\uc220 \uc608\uc220.jpg"},
"",
"",
L"",
L"\uc608\uc220 \uc608\uc220.jpg"},
{__LINE__,
"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
"",
"",
"",
"",
L"download",
L"\uc608\uc220 \uc608\uc220.jpg"},
{__LINE__, {__LINE__,
"http://www.google.com/", "http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg", "",
"attachment;", "", "", "", L"download", L"\uc608\uc220 \uc608\uc220.jpg"},
"", {__LINE__, "http://www.google.com/", "attachment;", "", "", "",
"", L"\uB2E4\uC6B4\uB85C\uB4DC", L"\uB2E4\uC6B4\uB85C\uB4DC"},
"", {__LINE__, "http://www.google.com/",
L"\uB2E4\uC6B4\uB85C\uB4DC",
L"\uB2E4\uC6B4\uB85C\uB4DC"},
{__LINE__,
"http://www.google.com/",
"attachment; filename=\"=?EUC-JP?Q?=B7=DD=BD=" "attachment; filename=\"=?EUC-JP?Q?=B7=DD=BD="
"D13=2Epng?=\"", "D13=2Epng?=\"",
"", "", "", "", L"download", L"\u82b8\u88533.png"},
"", {__LINE__, "http://www.example.com/images?id=3",
"", "attachment; filename=caf\xc3\xa9.png", "iso-8859-1", "", "", L"",
L"download",
L"\u82b8\u88533.png"},
{__LINE__,
"http://www.example.com/images?id=3",
"attachment; filename=caf\xc3\xa9.png",
"iso-8859-1",
"",
"",
L"",
L"caf\u00e9.png"}, L"caf\u00e9.png"},
{__LINE__, {__LINE__, "http://www.example.com/images?id=3",
"http://www.example.com/images?id=3", "attachment; filename=caf\xe5.png", "windows-1253", "", "", L"",
"attachment; filename=caf\xe5.png",
"windows-1253",
"",
"",
L"",
L"caf\u03b5.png"}, L"caf\u03b5.png"},
{// Invalid C-D header. Name value is skipped now. {// Invalid C-D header. Name value is skipped now.
__LINE__, __LINE__, "http://www.example.com/file?id=3",
"http://www.example.com/file?id=3", "attachment; name=\xcf\xc2\xd4\xd8.zip", "GBK", "", "", L"", L"file"},
"attachment; name=\xcf\xc2\xd4\xd8.zip",
"GBK",
"",
"",
L"",
L"file"},
{// Invalid C-D header. Extracts filename from url. {// Invalid C-D header. Extracts filename from url.
__LINE__, __LINE__, "http://www.google.com/test.html",
"http://www.google.com/test.html", "attachment; filename==?iiso88591?Q?caf=EG?=", "", "", "", L"",
"attachment; filename==?iiso88591?Q?caf=EG?=",
"",
"",
"",
L"",
L"test.html"}, L"test.html"},
// about: and data: URLs // about: and data: URLs
{__LINE__, "about:chrome", "", "", "", "", L"", L"download"}, {__LINE__, "about:chrome", "", "", "", "", L"", L"download"},
{__LINE__, "data:,looks/like/a.path", "", "", "", "", L"", L"download"}, {__LINE__, "data:,looks/like/a.path", "", "", "", "", L"", L"download"},
{__LINE__, {__LINE__, "data:text/plain;base64,VG8gYmUgb3Igbm90IHRvIGJlLg=", "", "", "",
"data:text/plain;base64,VG8gYmUgb3Igbm90IHRvIGJlLg=", "", L"", L"download"},
"", {__LINE__, "data:,looks/like/a.path", "", "", "", "",
"", L"default_filename_is_given", L"default_filename_is_given"},
"", {__LINE__, "data:,looks/like/a.path", "", "", "", "",
"",
L"",
L"download"},
{__LINE__,
"data:,looks/like/a.path",
"",
"",
"",
"",
L"default_filename_is_given",
L"default_filename_is_given"},
{__LINE__,
"data:,looks/like/a.path",
"",
"",
"",
"",
L"\u65e5\u672c\u8a9e", // Japanese Kanji. L"\u65e5\u672c\u8a9e", // Japanese Kanji.
L"\u65e5\u672c\u8a9e"}, L"\u65e5\u672c\u8a9e"},
{// The filename encoding is specified by the referrer charset. {// The filename encoding is specified by the referrer charset.
__LINE__, __LINE__, "http://example.com/V%FDvojov%E1%20psychologie.doc", "",
"http://example.com/V%FDvojov%E1%20psychologie.doc", "iso-8859-1", "", "", L"", L"V\u00fdvojov\u00e1 psychologie.doc"},
"",
"iso-8859-1",
"",
"",
L"",
L"V\u00fdvojov\u00e1 psychologie.doc"},
{// Suggested filename takes precedence over URL {// Suggested filename takes precedence over URL
__LINE__, __LINE__, "http://www.google.com/test", "", "", "suggested", "", L"",
"http://www.google.com/test",
"",
"",
"suggested",
"",
L"",
L"suggested"}, L"suggested"},
{// The content-disposition has higher precedence over the suggested name. {// The content-disposition has higher precedence over the suggested name.
__LINE__, __LINE__, "http://www.google.com/test", "attachment; filename=test.html",
"http://www.google.com/test", "", "suggested", "", L"", L"test.html"},
"attachment; filename=test.html", {__LINE__, "http://www.google.com/test", "attachment; filename=test",
"", "utf-8", "", "image/png", L"", L"test"},
"suggested",
"",
L"",
L"test.html"},
{__LINE__,
"http://www.google.com/test",
"attachment; filename=test",
"utf-8",
"",
"image/png",
L"",
L"test"},
#if 0 #if 0
{ // The filename encoding doesn't match the referrer charset, the system { // The filename encoding doesn't match the referrer charset, the system
// charset, or UTF-8. // charset, or UTF-8.
...@@ -695,95 +486,46 @@ TEST(FilenameUtilTest, GenerateFileName) { ...@@ -695,95 +486,46 @@ TEST(FilenameUtilTest, GenerateFileName) {
}, },
#endif #endif
// Raw 8bit characters in C-D // Raw 8bit characters in C-D
{__LINE__, {__LINE__, "http://www.example.com/images?id=3",
"http://www.example.com/images?id=3", "attachment; filename=caf\xc3\xa9.png", "iso-8859-1", "", "image/png", L"",
"attachment; filename=caf\xc3\xa9.png",
"iso-8859-1",
"",
"image/png",
L"",
L"caf\u00e9.png"}, L"caf\u00e9.png"},
{__LINE__, {__LINE__, "http://www.example.com/images?id=3",
"http://www.example.com/images?id=3", "attachment; filename=caf\xe5.png", "windows-1253", "", "image/png", L"",
"attachment; filename=caf\xe5.png",
"windows-1253",
"",
"image/png",
L"",
L"caf\u03b5.png"}, L"caf\u03b5.png"},
{// No 'filename' keyword in the disposition, use the URL {// No 'filename' keyword in the disposition, use the URL
__LINE__, __LINE__, "http://www.evil.com/my_download.txt", "a_file_name.txt", "", "",
"http://www.evil.com/my_download.txt", "text/plain", L"download", L"my_download.txt"},
"a_file_name.txt",
"",
"",
"text/plain",
L"download",
L"my_download.txt"},
{// Spaces in the disposition file name {// Spaces in the disposition file name
__LINE__, __LINE__, "http://www.frontpagehacker.com/a_download.exe",
"http://www.frontpagehacker.com/a_download.exe", "filename=My Downloaded File.exe", "", "", "application/octet-stream",
"filename=My Downloaded File.exe", L"download", L"My Downloaded File.exe"},
"",
"",
"application/octet-stream",
L"download",
L"My Downloaded File.exe"},
{// % encoded {// % encoded
__LINE__, __LINE__, "http://www.examples.com/",
"http://www.examples.com/",
"attachment; " "attachment; "
"filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"", "filename=\"%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg\"",
"", "", "", "image/jpeg", L"download", L"\uc608\uc220 \uc608\uc220.jpg"},
"",
"image/jpeg",
L"download",
L"\uc608\uc220 \uc608\uc220.jpg"},
{// Invalid C-D header. Name value is skipped now. {// Invalid C-D header. Name value is skipped now.
__LINE__, __LINE__, "http://www.examples.com/q.cgi?id=abc",
"http://www.examples.com/q.cgi?id=abc", "attachment; name=abc de.pdf", "", "", "application/octet-stream",
"attachment; name=abc de.pdf", L"download", L"q.cgi"},
"", {__LINE__, "http://www.example.com/path",
"", "filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"", "", "", "image/png",
"application/octet-stream",
L"download",
L"q.cgi"},
{__LINE__,
"http://www.example.com/path",
"filename=\"=?EUC-JP?Q?=B7=DD=BD=D13=2Epng?=\"",
"",
"",
"image/png",
L"download", L"download",
L"\x82b8\x8853" L"\x82b8\x8853"
L"3.png"}, L"3.png"},
{// The following two have invalid CD headers and filenames come from the {// The following two have invalid CD headers and filenames come from the
// URL. // URL.
__LINE__, __LINE__, "http://www.example.com/test%20123",
"http://www.example.com/test%20123", "attachment; filename==?iiso88591?Q?caf=EG?=", "", "", "image/jpeg",
"attachment; filename==?iiso88591?Q?caf=EG?=", L"download", L"test 123" JPEG_EXT},
"",
"",
"image/jpeg",
L"download",
L"test 123" JPEG_EXT},
{__LINE__, {__LINE__,
"http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg", "http://www.google.com/%EC%98%88%EC%88%A0%20%EC%98%88%EC%88%A0.jpg",
"malformed_disposition", "malformed_disposition", "", "", "image/jpeg", L"download",
"",
"",
"image/jpeg",
L"download",
L"\uc608\uc220 \uc608\uc220.jpg"}, L"\uc608\uc220 \uc608\uc220.jpg"},
{// Invalid C-D. No filename from URL. Falls back to 'download'. {// Invalid C-D. No filename from URL. Falls back to 'download'.
__LINE__, __LINE__, "http://www.google.com/path1/path2/",
"http://www.google.com/path1/path2/", "attachment; filename==?iso88591?Q?caf=E3?", "", "", "image/jpeg",
"attachment; filename==?iso88591?Q?caf=E3?", L"download", L"download" JPEG_EXT},
"",
"",
"image/jpeg",
L"download",
L"download" JPEG_EXT},
}; };
// Tests filename generation. Once the correct filename is // Tests filename generation. Once the correct filename is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment