Source/WebKit2:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 05:02:48 +0000 (05:02 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jun 2017 05:02:48 +0000 (05:02 +0000)
[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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit2/UIProcess/WebProcessPool.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AdditionalReadAccessAllowedURLs.mm

index 23beb5254f7e1ac471929bf38491b75b450e5be7..9af06511847ac3735c2bcbaf9b443ca716c586d9 100644 (file)
@@ -1,3 +1,24 @@
+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
index 443927f33393c65fb39f056438f5cc5f868abbba..087107a7906129abf417328126c3f773b60e422e 100644 (file)
@@ -31,6 +31,7 @@
 #include "WebsiteDataStore.h"
 #include <wtf/Ref.h>
 #include <wtf/Vector.h>
+#include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 namespace API {
@@ -99,8 +100,8 @@ public:
     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; }
@@ -158,7 +159,7 @@ private:
     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;
index 379228768de36f569c798eb95e7d1ae163d5f3c0..8fb4c73ccc0f2218a10fdcc3a2579ce08ef67cf6 100644 (file)
 
     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)
index ca3d6cba97ee897b39a7eecf67b3ace8a6aef408..22b046f9b2fb988b8a4f3c8a22e12376c8b08562 100644 (file)
@@ -625,7 +625,7 @@ void WebProcessPool::resolvePathsForSandboxExtensions()
 
     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();
 }
index 90326467c6478ed9d56d1c72e5311d6e2f476c0f..52a8eb3dd5725d4b604939b4a9dd43450e4532a5 100644 (file)
@@ -1,3 +1,13 @@
+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
index e86da2b9d05715eb08734b9de4d340b0d60aa481..92cb06693233ad7c66717f439e1d5dc12716b458 100644 (file)
@@ -56,6 +56,10 @@ TEST(WebKit2, AdditionalReadAccessAllowedURLs)
     }
     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));