[DOM] Filter out symlinks for webkitdirectory.

This is effectively a back-out of the following patches from Bug 1274959
except we add comments and test coverage:

- Part 1 which made the DirectoryListingTask include symlinks in the
  results as exposed by Directory.getFilesAndDirectories.
- Part 3 which made GetFilesHelper include symlinks in the results.

Test coverage for getFilesAndDirectories is provided by
dom/filesystem/tests/test_basic.html by way of changes to its included
file dom/filesystem/tests/filesystem_commons.js and changes to the
createTreeFile helper in dom/filesystem/tests/script_fileList.js.
Test coverage for GetFilesHelper is provided by
dom/filesystem/tests/test_webkitdirectory.html and changes to the
createTestFile helper in dom/filesystem/tests/script_fileList.js.

Commenting out either of the `isLink` test in the relevant C++ code will
cause the given tests to fail on non-windows platforms.
This commit is contained in:
Moonchild 2023-07-05 21:55:00 +02:00 committed by roytam1
commit a299eaa965
6 changed files with 134 additions and 87 deletions

View file

@ -340,9 +340,14 @@ GetDirectoryListingTaskParent::IOWork()
nsCOMPtr<nsIFile> currFile = do_QueryInterface(supp);
MOZ_ASSERT(currFile);
bool isSpecial, isFile;
if (NS_WARN_IF(NS_FAILED(currFile->IsSpecial(&isSpecial))) ||
isSpecial) {
bool isLink, isSpecial, isFile;
if (NS_WARN_IF(NS_FAILED(currFile->IsSymlink(&isLink)) ||
NS_FAILED(currFile->IsSpecial(&isSpecial))) ||
// Although we allow explicit individual selection of symlinks via the
// file picker, we do not process symlinks in directory traversal. Our
// specific policy decision is documented at
// https://bugzilla.mozilla.org/show_bug.cgi?id=1813299#c20
isLink || isSpecial) {
continue;
}
if (NS_WARN_IF(NS_FAILED(currFile->IsFile(&isFile)) ||