[webkit-changes] [WebKit/WebKit] 22dc25: Ensure file name is valid when saving web page res...
Sihui
noreply at github.com
Thu Oct 5 22:13:47 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 22dc25be180b6bfb18f6012b963885cc4e2797d1
https://github.com/WebKit/WebKit/commit/22dc25be180b6bfb18f6012b963885cc4e2797d1
Author: Sihui Liu <sihui_liu at apple.com>
Date: 2023-10-05 (Thu, 05 Oct 2023)
Changed paths:
M Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
M Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm
Log Message:
-----------
Ensure file name is valid when saving web page resources to disk
https://bugs.webkit.org/show_bug.cgi?id=262642
rdar://116419303
Reviewed by Ryosuke Niwa.
We currently use the last component of URL as file name, and that could lead to file system error, because a valid URL
component may not be a valid file name. To fix that, we are going to generate valid file name based on last component
by:
1. encoding escape characters of file system.
2. ensuring length is smaller than 255 bytes.
3. appending sequence number when it's taken by other subresource file.
4. falling back to default file name when last component is empty.
Test: WebArchive.SaveResourcesValidFileName
* Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::generateValidFileName):
(WebCore::LegacyWebArchive::create):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/CreateWebArchive.mm:
Canonical link: https://commits.webkit.org/268970@main
More information about the webkit-changes
mailing list