Skip to content

Commit

Permalink
FSA: Relax file name checks in the BucketFS
Browse files Browse the repository at this point in the history
Unlike when saving files to the local file system, the names of files in
the the Bucket File System (a.k.a. OPFS) are obfuscated before they end
up on disk - if they even end up on disk at all.

As such, we don't need to perform the same name sanitization and
obfuscation for these files as we do for files that end up on the
user-visible file system.

See whatwg/fs#93 for context

Bug: 1399536
Change-Id: I019b393b731cd20aa4c45eade4eca19b6633e9cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4492076
Reviewed-by: Daseul Lee <[email protected]>
Commit-Queue: Austin Sullivan <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1206676}
  • Loading branch information
a-sully authored and cookiecrook committed Oct 11, 2023
1 parent f7cbc6e commit 826433d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
10 changes: 3 additions & 7 deletions fs/resources/test-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ const LOCK_ACCESS = {
};

// Array of separators used to separate components in hierarchical paths.
let kPathSeparators;
if (navigator.userAgent.includes('Windows NT')) {
// Windows uses both '/' and '\' as path separators.
kPathSeparators = ['/', '\\'];
} else {
kPathSeparators = ['/'];
}
// Consider both '/' and '\' as path separators to ensure file names are
// platform-agnostic.
let kPathSeparators = ['/', '\\'];

async function getFileSize(handle) {
const file = await handle.getFile();
Expand Down
14 changes: 2 additions & 12 deletions fs/script-tests/FileSystemFileHandle-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,15 @@ directory_test(async (t, root) => {
assert_array_equals(await getSortedDirectoryEntries(root), ['file-1']);
}, 'move(name) can be called multiple times');

directory_test(async (t, root) => {
const dir = await root.getDirectoryHandle('dir', {create: true});
const handle = await createFileWithContents(t, 'file-before', 'foo', dir);
await promise_rejects_js(t, TypeError, handle.move('Lorem.'));

assert_array_equals(await getSortedDirectoryEntries(root), ['dir/']);
assert_array_equals(await getSortedDirectoryEntries(dir), ['file-before']);
assert_equals(await getFileContents(handle), 'foo');
assert_equals(await getFileSize(handle), 3);
}, 'move(name) with a name with a trailing period should fail');

directory_test(async (t, root) => {
const handle = await createFileWithContents(t, 'file-before', 'foo', root);
await promise_rejects_js(t, TypeError, handle.move('test/test'));
await promise_rejects_js(t, TypeError, handle.move('test\\test'));

assert_array_equals(await getSortedDirectoryEntries(root), ['file-before']);
assert_equals(await getFileContents(handle), 'foo');
assert_equals(await getFileSize(handle), 3);
}, 'move(name) with a name with invalid characters should fail');
}, 'move(name) with a name with path separators should fail');

directory_test(async (t, root) => {
const handle = await createFileWithContents(t, 'file-before', 'abc', root);
Expand Down

0 comments on commit 826433d

Please sign in to comment.