Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 25f7ce345ae8a6d20feb88f72db51f9757c26bb3
https://github.com/WebKit/WebKit/commit/25f7ce345ae8a6d20feb88f72db51f9757c26bb3
Author: Chris Dumez <[email protected]>
Date: 2026-09-12 (Sat, 12 Sep 2026)
Changed paths:
M Source/JavaScriptCore/API/JSScript.mm
M Source/JavaScriptCore/jit/ExecutableAllocator.cpp
M Source/WTF/wtf/FileSystem.h
M Source/WTF/wtf/StdLibExtras.h
M Source/WTF/wtf/cf/FileSystemCF.cpp
M Source/WTF/wtf/cocoa/FileSystemCocoa.mm
M Source/WTF/wtf/glib/FileSystemGlib.cpp
M Source/WTF/wtf/playstation/FileSystemPlayStation.cpp
M Source/WTF/wtf/posix/FileSystemPOSIX.cpp
M Source/WTF/wtf/text/CString.h
M Source/WTF/wtf/win/FileSystemWin.cpp
M Source/WebCore/PAL/pal/system/glib/SleepDisablerGLib.cpp
M Source/WebCore/platform/glib/FileMonitorGLib.cpp
M Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
M Source/WebCore/platform/network/soup/SoupNetworkSession.cpp
M Source/WebCore/platform/network/soup/WebKitFormDataInputStream.cpp
M Source/WebCore/platform/sql/SQLiteDatabase.cpp
M Source/WebCore/platform/sql/SQLiteFileSystem.cpp
M Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm
M Source/WebKit/NetworkProcess/cache/NetworkCache.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
M Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm
M Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelGLib.cpp
M Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm
M Source/WebKit/Shared/Extensions/WebExtensionSQLiteDatabase.cpp
M Source/WebKit/Shared/SandboxExtension.h
M Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp
M Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm
M Source/WebKit/UIProcess/API/glib/WebKitFileChooserRequest.cpp
M Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
M Source/WebKit/WebProcess/InjectedBundle/glib/InjectedBundleGlib.cpp
M Source/WebKitLegacy/mac/WebView/WebPDFView.mm
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WTF/cocoa/CStringCocoa.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKPage/cocoa/FetchLocalFile.mm
M Tools/TestWebKitAPI/glib/WPEPlatform/WPEPlatformTestMain.cpp
M Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp
M Tools/WebKitTestRunner/InjectedBundle/glib/ActivateFontsGlib.cpp
M Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp
M Tools/WebKitTestRunner/TestController.cpp
Log Message:
-----------
Make FileSystem::fileSystemRepresentation() return a UTF8CString and keep its
consumers typed
https://bugs.webkit.org/show_bug.cgi?id=324034
Reviewed by Yusuke Suzuki.
Follow-up to 320652@main and 320980@main. JavaScriptCore has no bare-CString
producers left;
FileSystem.h has the largest remaining cluster.
fileSystemRepresentation() is already UTF-8 wherever it is implemented. The
POSIX version, used by the
GLib and PlayStation ports, is literally "return path.utf8()", so it was
slicing the encoding straight
back off. The CF version uses CFStringGetFileSystemRepresentation(), and
Darwin's representation is
UTF-8 - canonically decomposed, but UTF-8. Only Windows disagreed, converting
with CP_ACP, the active
ANSI code page; it now uses CP_UTF8 to match the type. currentExecutableName(),
currentExecutablePath()
and webkitTopLevelDirectory() are typed alongside it.
Consumers that hand the bytes to a C interface - open(), unlink(), statvfs(),
sqlite3_open_v2(),
sandbox_*(), g_file_new_for_path() and friends - adopt legacyCStringPointer(),
which is the irreducible
remainder 320917@main describes. Everywhere else a caller reaching for const
char* means missing API,
so the rest of this patch adds it.
createTemporaryFileInDirectory() returned the representation even though none
of its five callers
wanted bytes; it was an implementation detail of mkstemps() needing a mutable
buffer. It returns a
String now, like openTemporaryFile() above it, converting once with
String::fromUTF8() - equivalent
here, since CFStringCreateWithFileSystemRepresentation() is a plain UTF-8
decode. Every use of the
result gets shorter, and FetchLocalFile.mm now handles its paths identically
whichever factory
produced them. Dropping .span() also fixes a latent bug: StringView's
std::span<const char>
constructor was decoding those UTF-8 path bytes as Latin-1.
CStringWithEncoding gains createNSString(), which picks the NSStringEncoding
from the type. ASCII
decodes as Latin-1, as ASCIILiteral::createNSString() already does, because
NSASCIIStringEncoding
returns nil for the mislabeled byte only newUninitialized() can introduce.
SandboxExtensionImpl::create() forwarded a const char* to
sandbox_extension_issue_*(), so six callers
each unwrapped a string for it; it takes a UTF8CString and unwraps once.
WTFLogAlways() has no SAFE_ variant today, unlike printf(), fprintf(),
snprintf() and dataLogF(),
because it is annotated WTF_ATTRIBUTE_NSSTRING: %@ reaches
CFStringCreateWithFormatAndArguments(), and
safePrintfType()'s NSString* overload would hand that a char pointer where it
expects an object,
breaking the 41 call sites using %@. SAFE_WTFLOGALWAYS therefore goes through a
new
safeNSStringPrintfType(), which passes object pointers through untouched and
delegates everything else,
so the 14 getprogname() sites in AuxiliaryProcessMac.mm can be typed via the
new Cocoa
currentExecutableName().
Tests: Tools/TestWebKitAPI/Tests/WTF/cocoa/CStringCocoa.mm
Tools/TestWebKitAPI/Tests/WebKit/WKPage/cocoa/FetchLocalFile.mm
* Source/JavaScriptCore/API/JSScript.mm:
(validateBytecodeCachePath):
* Source/JavaScriptCore/jit/ExecutableAllocator.cpp:
(JSC::dumpJITMemory):
* Source/WTF/wtf/FileSystem.h:
* Source/WTF/wtf/StdLibExtras.h:
(WTF::safeNSStringPrintfType):
* Source/WTF/wtf/cf/FileSystemCF.cpp:
(WTF::FileSystem::fileSystemRepresentation):
* Source/WTF/wtf/cocoa/FileSystemCocoa.mm:
(WTF::FileSystemImpl::extractTemporaryZipArchive):
(WTF::FileSystemImpl::createTemporaryFileInDirectory):
(WTF::FileSystemImpl::markPurgeable):
(WTF::FileSystemImpl::currentExecutableName):
* Source/WTF/wtf/glib/FileSystemGlib.cpp:
(WTF::FileSystemImpl::validRepresentation):
(WTF::FileSystemImpl::filenameForDisplay):
(WTF::FileSystemImpl::currentExecutablePath):
(WTF::FileSystemImpl::currentExecutableName):
(WTF::FileSystemImpl::webkitTopLevelDirectory):
* Source/WTF/wtf/playstation/FileSystemPlayStation.cpp:
(WTF::FileSystemImpl::fileTypePotentiallyFollowingSymLinks):
(WTF::FileSystemImpl::volumeFreeSpace):
(WTF::FileSystemImpl::volumeCapacity):
(WTF::FileSystemImpl::listDirectorySub):
(WTF::FileSystemImpl::realPath):
* Source/WTF/wtf/posix/FileSystemPOSIX.cpp:
(WTF::FileSystemImpl::openFile):
(WTF::FileSystemImpl::fileCreationTime):
(WTF::FileSystemImpl::volumeFileBlockSize):
(WTF::FileSystemImpl::fileSystemRepresentation):
(WTF::FileSystemImpl::fileExists):
(WTF::FileSystemImpl::deleteFile):
(WTF::FileSystemImpl::makeAllDirectories):
* Source/WTF/wtf/text/CString.h:
* Source/WTF/wtf/win/FileSystemWin.cpp:
(WTF::FileSystemImpl::fileSystemRepresentation):
* Source/WebCore/platform/glib/FileMonitorGLib.cpp:
(WebCore::FileMonitor::FileMonitor):
* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::ensureGStreamerInitialized):
* Source/WebCore/platform/network/soup/SoupNetworkSession.cpp:
(WebCore::SoupNetworkSession::setHSTSPersistentStorage):
(WebCore::SoupNetworkSession::clearOldSoupCache):
* Source/WebCore/platform/network/soup/WebKitFormDataInputStream.cpp:
(webkitFormDataInputStreamCreateNextStream):
* Source/WebCore/platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::open):
* Source/WebCore/platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::setCanSuspendLockedFileAttribute):
* Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
(WebKit::Download::resume):
* Source/WebKit/NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::Cache):
* Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::fileTimes):
* Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm:
(WebKit::NetworkCache::IOChannel::IOChannel):
* Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm:
(WebKit::SandboxExtensionImpl::create):
(WebKit::SandboxExtensionImpl::sandboxExtensionForType):
(WebKit::SandboxExtensionImpl::SandboxExtensionImpl):
(WebKit::SandboxExtension::createHandleWithoutResolvingPath):
(WebKit::SandboxExtension::createHandleForTemporaryFile):
(WebKit::SandboxExtension::createHandleForGenericExtension):
(WebKit::SandboxExtension::createHandleForMachLookup):
(WebKit::SandboxExtension::createHandleForReadByAuditToken):
(WebKit::SandboxExtension::createHandleForIOKitClassExtension):
* Source/WebKit/Shared/Extensions/WebExtensionSQLiteDatabase.cpp:
(WebExtensionSQLiteDatabase::openWithAccessType):
* Source/WebKit/Shared/SandboxExtension.h:
* Source/WebKit/Shared/glib/ProcessExecutablePathGLib.cpp:
(WebKit::getExecutablePath):
* Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::setAndSerializeSandboxParameters):
(WebKit::ensureSandboxCacheDirectory):
(WebKit::compileAndCacheSandboxProfile):
(WebKit::tryApplyCachedSandbox):
(WebKit::compileAndApplySandboxSlowCase):
(WebKit::applySandbox):
(WebKit::populateSandboxInitializationParameters):
(WebKit::AuxiliaryProcess::initializeSandbox):
* Source/WebKit/UIProcess/API/glib/WebKitFileChooserRequest.cpp:
(webkit_file_chooser_request_get_selected_files):
* Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
(WebKit::bubblewrapSpawn):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
* Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:
(WebKit::pathToPDFOnDisk):
* Source/WebKit/WebProcess/InjectedBundle/glib/InjectedBundleGlib.cpp:
(WebKit::InjectedBundle::initialize):
* Source/WebKitLegacy/mac/WebView/WebPDFView.mm:
(-[WebPDFView _path]):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WTF/cocoa/CStringCocoa.mm: Added.
(TestWebKitAPI::requires):
(TestWebKitAPI::TEST(WTF, CStringWithEncodingCreateNSString)):
* Tools/TestWebKitAPI/Tests/WebKit/WKPage/cocoa/FetchLocalFile.mm:
(TEST(WebKit, FetchLocalFile)):
(TEST(WebKit, FetchLocalFileInParentDirectory)):
* Tools/TestWebKitAPI/glib/WPEPlatform/WPEPlatformTestMain.cpp:
(main):
* Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.cpp:
(main):
* Tools/WebKitTestRunner/InjectedBundle/glib/ActivateFontsGlib.cpp:
(WTR::activateFonts):
* Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
(WTR::TestRunner::pathToLocalResource):
Canonical link: https://commits.webkit.org/320998@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications