Commit 38242dea authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Zip Archiver: Allow to auto-detect UTF-8 file name when EFS is 0.

We saw a ZIP file created on macOS stores file names in UTF-8 encoding
but the language encoding flag in the general purpose bit is not set.
This change will cover some of such cases when the encoding detector
detected that encoding.

Bug: 903664
Test: browser_tests --gtest_filter=ZipFiles/FilesAppBrowserTest.Test/*
Test: manually verified using the ZIP attached to the bug
Change-Id: I5ef488cf5a0ba04feee9e8d2025054e16785f832
Reviewed-on: https://chromium-review.googlesource.com/c/1328623Reviewed-by: default avatarAnand Mistry <amistry@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607141}
parent 91f86ad2
...@@ -259,6 +259,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P( ...@@ -259,6 +259,7 @@ WRAPPED_INSTANTIATE_TEST_CASE_P(
::testing::Values(ZipCase("zipFileOpenDownloads").InGuestMode(), ::testing::Values(ZipCase("zipFileOpenDownloads").InGuestMode(),
ZipCase("zipFileOpenDownloads"), ZipCase("zipFileOpenDownloads"),
ZipCase("zipFileOpenDownloadsShiftJIS"), ZipCase("zipFileOpenDownloadsShiftJIS"),
ZipCase("zipFileOpenDownloadsMacOs"),
ZipCase("zipFileOpenDownloadsWithAbsolutePaths"), ZipCase("zipFileOpenDownloadsWithAbsolutePaths"),
ZipCase("zipFileOpenDrive").DisableDriveFs(), ZipCase("zipFileOpenDrive").DisableDriveFs(),
ZipCase("zipFileOpenDrive").EnableDriveFs(), ZipCase("zipFileOpenDrive").EnableDriveFs(),
......
...@@ -219,7 +219,8 @@ unpacker.Volume.ENCODING_TABLE = { ...@@ -219,7 +219,8 @@ unpacker.Volume.ENCODING_TABLE = {
// supproted by TextEncoder class. We may add more encodings but only if there's // supproted by TextEncoder class. We may add more encodings but only if there's
// evidence that such archives are widespread. // evidence that such archives are widespread.
unpacker.Volume.MIME_TO_ENCODING_TABLE = { unpacker.Volume.MIME_TO_ENCODING_TABLE = {
'Shift_JIS': 'Shift_JIS' 'Shift_JIS': 'Shift_JIS',
'UTF-8': 'UTF-8', // macOS stores file names in UTF-8 without setting EFS
}; };
/** /**
......
...@@ -43,6 +43,17 @@ function getUnzippedFileListRowEntriesSjisSubdir() { ...@@ -43,6 +43,17 @@ function getUnzippedFileListRowEntriesSjisSubdir() {
]; ];
} }
/**
* Returns the expected file list row entries after opening (unzipping) the
* ENTRIES.zipArchiveMacOs file list entry.
*/
function getUnzippedFileListRowEntriesMacOsRoot() {
return [
// File name in non-ASCII (UTF-8) characters.
['ファイル.dat', '16 bytes', 'DAT file', 'Jul 8, 2001, 12:34 PM']
];
}
/** /**
* Returns the expected file list row entries after opening (unzipping) the * Returns the expected file list row entries after opening (unzipping) the
* ENTRIES.zipArchiveWithAbsolutePaths file list entry. * ENTRIES.zipArchiveWithAbsolutePaths file list entry.
...@@ -466,3 +477,37 @@ testcase.zipFileOpenDownloadsShiftJIS = function() { ...@@ -466,3 +477,37 @@ testcase.zipFileOpenDownloadsShiftJIS = function() {
}, },
]); ]);
}; };
/**
* Tests zip file open (aka unzip) from Downloads. The file name in the archive
* is encoded in UTF-8, but the language encoding flag bit is set to 0.
*/
testcase.zipFileOpenDownloadsMacOs = function() {
let appId;
StepsRunner.run([
// Open Files app on Downloads containing a zip file.
function() {
setupAndWaitUntilReady(
null, RootPath.DOWNLOADS, this.next, [ENTRIES.zipArchiveMacOs], []);
},
// Select the zip file.
function(result) {
appId = result.windowId;
remoteCall.callRemoteTestUtil('selectFile', appId, ['archive_macos.zip'])
.then(this.next);
},
// Press the Enter key.
function(result) {
chrome.test.assertTrue(!!result, 'selectFile failed');
const key = ['#file-list', 'Enter', false, false, false];
remoteCall.callRemoteTestUtil('fakeKeyDown', appId, key, this.next);
},
// Check: the zip file content should be shown (unzip).
function(result) {
chrome.test.assertTrue(!!result, 'fakeKeyDown failed');
const files = getUnzippedFileListRowEntriesMacOsRoot();
remoteCall.waitForFiles(appId, files).then(this.next);
},
]);
};
...@@ -682,6 +682,17 @@ var ENTRIES = { ...@@ -682,6 +682,17 @@ var ENTRIES = {
typeText: 'Zip archive' typeText: 'Zip archive'
}), }),
zipArchiveMacOs: new TestEntryInfo({
type: EntryType.FILE,
sourceFileName: 'archive_macos.zip',
targetPath: 'archive_macos.zip',
mimeType: 'application/x-zip',
lastModifiedTime: 'Dec 21, 2018, 12:21 PM',
nameText: 'archive_macos.zip',
sizeText: '190 bytes',
typeText: 'Zip archive'
}),
zipArchiveWithAbsolutePaths: new TestEntryInfo({ zipArchiveWithAbsolutePaths: new TestEntryInfo({
type: EntryType.FILE, type: EntryType.FILE,
sourceFileName: 'absolute_paths.zip', sourceFileName: 'absolute_paths.zip',
......
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