Changeset 217923 in webkit


Ignore:
Timestamp:
Jun 7, 2017 10:02:48 PM (7 years ago)
Author:
mitz@apple.com
Message:

Source/WebKit2:
[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):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r217914 r217923  
     12017-06-07  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin-1 paths
     4        https://bugs.webkit.org/show_bug.cgi?id=173086
     5
     6        Reviewed by Andy Estes.
     7
     8        We were incorrectly passing the fileSystemRepresentation of an NSURL into the WTF::String
     9        constructor that expects a Latin-1 string. However, in general, fileSystemRepresentation is
     10        not Latin-1.
     11
     12        * UIProcess/API/APIProcessPoolConfiguration.h: Changed m_additionalReadAccessAllowedPaths
     13          from a Vector<WTF::String> into a Vector<WTF::CString>.
     14
     15        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
     16        (-[_WKProcessPoolConfiguration additionalReadAccessAllowedURLs]): Updated for the change.
     17        (-[_WKProcessPoolConfiguration setAdditionalReadAccessAllowedURLs:]): Ditto.
     18
     19        * UIProcess/WebProcessPool.cpp:
     20        (WebKit::WebProcessPool::resolvePathsForSandboxExtensions): Ditto.
     21
    1222017-06-07  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h

    r217743 r217923  
    3232#include <wtf/Ref.h>
    3333#include <wtf/Vector.h>
     34#include <wtf/text/CString.h>
    3435#include <wtf/text/WTFString.h>
    3536
     
    100101    void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
    101102
    102     const Vector<WTF::String>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
    103     void setAdditionalReadAccessAllowedPaths(Vector<WTF::String>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
     103    const Vector<WTF::CString>& additionalReadAccessAllowedPaths() { return m_additionalReadAccessAllowedPaths; }
     104    void setAdditionalReadAccessAllowedPaths(Vector<WTF::CString>&& additionalReadAccessAllowedPaths) { m_additionalReadAccessAllowedPaths = additionalReadAccessAllowedPaths; }
    104105
    105106    bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
     
    159160    Vector<WTF::String> m_cachePartitionedURLSchemes;
    160161    Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
    161     Vector<WTF::String> m_additionalReadAccessAllowedPaths;
     162    Vector<WTF::CString> m_additionalReadAccessAllowedPaths;
    162163    bool m_fullySynchronousModeIsAllowedForTesting { false };
    163164    bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm

    r217728 r217923  
    111111    NSMutableArray *urls = [NSMutableArray arrayWithCapacity:paths.size()];
    112112    for (const auto& path : paths)
    113         [urls addObject:[NSURL fileURLWithPath:path]];
     113        [urls addObject:[NSURL fileURLWithFileSystemRepresentation:path.data() isDirectory:NO relativeToURL:nil]];
    114114
    115115    return urls;
     
    118118- (void)setAdditionalReadAccessAllowedURLs:(NSArray<NSURL *> *)additionalReadAccessAllowedURLs
    119119{
    120     Vector<String> paths;
     120    Vector<CString> paths;
    121121    paths.reserveInitialCapacity(additionalReadAccessAllowedURLs.count);
    122122    for (NSURL *url in additionalReadAccessAllowedURLs) {
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp

    r217743 r217923  
    626626    m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.reserveCapacity(m_configuration->additionalReadAccessAllowedPaths().size());
    627627    for (const auto& path : m_configuration->additionalReadAccessAllowedPaths())
    628         m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.uncheckedAppend(resolvePathForSandboxExtension(path));
     628        m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.uncheckedAppend(resolvePathForSandboxExtension(path.data()));
    629629
    630630    platformResolvePathsForSandboxExtensions();
  • trunk/Tools/ChangeLog

    r217920 r217923  
     12017-06-07  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] additionalReadAccessAllowedURLs doesn’t preserve non-Latin1 paths
     4        https://bugs.webkit.org/show_bug.cgi?id=173086
     5
     6        Reviewed by Andy Estes.
     7
     8        * TestWebKitAPI/Tests/WebKit2Cocoa/AdditionalReadAccessAllowedURLs.mm:
     9        (TEST):
     10
    1112017-06-07  Alexey Proskuryakov  <ap@apple.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AdditionalReadAccessAllowedURLs.mm

    r216203 r217923  
    5757    EXPECT_TRUE(exceptionRaised);
    5858
     59    NSURL *fileURLWithNonLatin1Path = [NSURL fileURLWithPath:@"/这是中文"];
     60    processPoolConfiguration.additionalReadAccessAllowedURLs = @[ fileURLWithNonLatin1Path ];
     61    EXPECT_TRUE([processPoolConfiguration.additionalReadAccessAllowedURLs.firstObject isEqual:fileURLWithNonLatin1Path]);
     62
    5963    char temporaryDirectory[PATH_MAX];
    6064    confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory));
Note: See TracChangeset for help on using the changeset viewer.