[Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin-1 paths
https://bugs.webkit.org/show_bug.cgi?id=173086
Reviewed by Andy Estes.
We were incorrectly passing the fileSystemRepresentation of an NSURL into the WTF::String
constructor that expects a Latin-1 string. However, in general, fileSystemRepresentation is
not Latin-1.
* UIProcess/API/APIProcessPoolConfiguration.h: Changed m_additionalReadAccessAllowedPaths
from a Vector<WTF::String> into a Vector<WTF::CString>.
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration additionalReadAccessAllowedURLs]): Updated for the change.
(-[_WKProcessPoolConfiguration setAdditionalReadAccessAllowedURLs:]): Ditto.
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::resolvePathsForSandboxExtensions): Ditto.
Tools:
[Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin1 paths
https://bugs.webkit.org/show_bug.cgi?id=173086
Reviewed by Andy Estes.
* TestWebKitAPI/Tests/WebKit2Cocoa/AdditionalReadAccessAllowedURLs.mm:
(TEST):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217923
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-06-07 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin-1 paths
+ https://bugs.webkit.org/show_bug.cgi?id=173086
+
+ Reviewed by Andy Estes.
+
+ We were incorrectly passing the fileSystemRepresentation of an NSURL into the WTF::String
+ constructor that expects a Latin-1 string. However, in general, fileSystemRepresentation is
+ not Latin-1.
+
+ * UIProcess/API/APIProcessPoolConfiguration.h: Changed m_additionalReadAccessAllowedPaths
+ from a Vector<WTF::String> into a Vector<WTF::CString>.
+
+ * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+ (-[_WKProcessPoolConfiguration additionalReadAccessAllowedURLs]): Updated for the change.
+ (-[_WKProcessPoolConfiguration setAdditionalReadAccessAllowedURLs:]): Ditto.
+
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::resolvePathsForSandboxExtensions): Ditto.
+
2017-06-07 Ryosuke Niwa <rniwa@webkit.org>
Crash inside WebKit::PluginView::getAuthenticationInfo
#include "WebsiteDataStore.h"
#include <wtf/Ref.h>
#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
namespace API {
const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; }
void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
- const Vector<WTF::String>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
- void setAdditionalReadAccessAllowedPaths(Vector<WTF::String>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
+ const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
+ void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
WTF::String m_javaScriptConfigurationDirectory;
Vector<WTF::String> m_cachePartitionedURLSchemes;
Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
- Vector<WTF::String> m_additionalReadAccessAllowedPaths;
+ Vector<WTF::CString> m_additionalReadAccessAllowedPaths;
bool m_fullySynchronousModeIsAllowedForTesting { false };
bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
Vector<WTF::String> m_overrideLanguages;
NSMutableArray *urls = [NSMutableArray arrayWithCapacity:paths.size()];
for (const auto& path : paths)
- [urls addObject:[NSURL fileURLWithPath:path]];
+ [urls addObject:[NSURL fileURLWithFileSystemRepresentation:path.data() isDirectory:NO relativeToURL:nil]];
return urls;
}
- (void)setAdditionalReadAccessAllowedURLs:(NSArray<NSURL *> *)additionalReadAccessAllowedURLs
{
- Vector<String> paths;
+ Vector<CString> paths;
paths.reserveInitialCapacity(additionalReadAccessAllowedURLs.count);
for (NSURL *url in additionalReadAccessAllowedURLs) {
if (!url.isFileURL)
m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.reserveCapacity(m_configuration->additionalReadAccessAllowedPaths().size());
for (const auto& path : m_configuration->additionalReadAccessAllowedPaths())
- m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.uncheckedAppend(resolvePathForSandboxExtension(path));
+ m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.uncheckedAppend(resolvePathForSandboxExtension(path.data()));
platformResolvePathsForSandboxExtensions();
}
+2017-06-07 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin1 paths
+ https://bugs.webkit.org/show_bug.cgi?id=173086
+
+ Reviewed by Andy Estes.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/AdditionalReadAccessAllowedURLs.mm:
+ (TEST):
+
2017-06-07 Alexey Proskuryakov <ap@apple.com>
Add High Sierra support to WebKit tools
}
EXPECT_TRUE(exceptionRaised);
+ NSURL *fileURLWithNonLatin1Path = [NSURL fileURLWithPath:@"/这是中文"];
+ processPoolConfiguration.additionalReadAccessAllowedURLs = @[ fileURLWithNonLatin1Path ];
+ EXPECT_TRUE([processPoolConfiguration.additionalReadAccessAllowedURLs.firstObject isEqual:fileURLWithNonLatin1Path]);
+
char temporaryDirectory[PATH_MAX];
confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory));