Changeset 291057 in webkit


Ignore:
Timestamp:
Mar 9, 2022 11:43:46 AM (4 months ago)
Author:
sihui_liu@apple.com
Message:

File System Access: disallows names that are not permitted by underlying file system
https://bugs.webkit.org/show_bug.cgi?id=237635
rdar://89291566

We use FileSystem::fileSystemRepresentation to convert input name to a name that is permitted in current file
system. This patch makes File System Access API to throw error if the input name does not match the converted
name.

Reviewed by Youenn Fablet.

  • NetworkProcess/storage/FileSystemStorageHandle.cpp:

(WebKit::isValidFileName):
(WebKit::FileSystemStorageHandle::requestCreateHandle):
(WebKit::FileSystemStorageHandle::removeEntry):
(WebKit::FileSystemStorageHandle::move):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r291056 r291057  
     12022-03-09  Sihui Liu  <sihui_liu@apple.com>
     2
     3        File System Access: disallows names that are not permitted by underlying file system
     4        https://bugs.webkit.org/show_bug.cgi?id=237635
     5        rdar://89291566
     6
     7        We use FileSystem::fileSystemRepresentation to convert input name to a name that is permitted in current file
     8        system. This patch makes File System Access API to throw error if the input name does not match the converted
     9        name.
     10
     11        Reviewed by Youenn Fablet.
     12
     13        * NetworkProcess/storage/FileSystemStorageHandle.cpp:
     14        (WebKit::isValidFileName):
     15        (WebKit::FileSystemStorageHandle::requestCreateHandle):
     16        (WebKit::FileSystemStorageHandle::removeEntry):
     17        (WebKit::FileSystemStorageHandle::move):
     18
    1192022-03-09  Jon Lee  <jonlee@apple.com>
    220
  • trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp

    r291014 r291057  
    9292}
    9393
    94 static bool isValidFileName(const String& name)
    95 {
    96     return !name.isEmpty() && name != "." && name != ".." && !name.contains(pathSeparator);
     94static bool isValidFileName(const String& directory, const String& name)
     95{
     96    // https://wicg.github.io/file-system-access/#valid-file-name
     97    if (name.isEmpty() || (name == ".") || (name == "..") || name.contains(pathSeparator))
     98        return false;
     99
     100    return FileSystem::pathFileName(FileSystem::pathByAppendingComponent(directory, name)) == name;
    97101}
    98102
     
    105109        return makeUnexpected(FileSystemStorageError::Unknown);
    106110
    107     // https://wicg.github.io/file-system-access/#valid-file-name
    108     if (!isValidFileName(name))
     111    if (!isValidFileName(m_path, name))
    109112        return makeUnexpected(FileSystemStorageError::InvalidName);
    110113
     
    128131        return FileSystemStorageError::TypeMismatch;
    129132
    130     if (!isValidFileName(name))
     133    if (!isValidFileName(m_path, name))
    131134        return FileSystemStorageError::InvalidName;
    132135
     
    249252        return FileSystemStorageError::Unknown;
    250253
    251     if (!isValidFileName(newName))
     254    if (!isValidFileName(path, newName))
    252255        return FileSystemStorageError::InvalidName;
    253256
Note: See TracChangeset for help on using the changeset viewer.