Changeset 215807 in webkit


Ignore:
Timestamp:
Apr 26, 2017 10:08:51 AM (7 years ago)
Author:
achristensen@apple.com
Message:

Encoded filename should be decoded for WKContentExtension.identifier
https://bugs.webkit.org/show_bug.cgi?id=171316

Reviewed by Andy Estes.

Source/WebCore:

  • platform/FileSystem.h:

Source/WebKit2:

  • UIProcess/API/APIContentExtensionStore.cpp:

(API::createExtension):
(API::ContentExtensionStore::lookupContentExtension):
(API::ContentExtensionStore::getAvailableContentExtensionIdentifiers):

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKit2Cocoa/WKContentExtensionStore.mm: Copied from Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm.

(TEST_F):

  • TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm: Removed.
Location:
trunk
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r215806 r215807  
     12017-04-25  Alex Christensen  <achristensen@webkit.org>
     2
     3        Encoded filename should be decoded for WKContentExtension.identifier
     4        https://bugs.webkit.org/show_bug.cgi?id=171316
     5
     6        Reviewed by Andy Estes.
     7
     8        * platform/FileSystem.h:
     9
    1102017-04-26  Frederic Wang  <fwang@igalia.com>
    211
  • trunk/Source/WebCore/platform/FileSystem.h

    r215290 r215807  
    191191// Encode a string for use within a file name.
    192192WEBCORE_EXPORT String encodeForFileName(const String&);
    193 String decodeFromFilename(const String&);
     193WEBCORE_EXPORT String decodeFromFilename(const String&);
    194194
    195195WEBCORE_EXPORT bool filesHaveSameVolume(const String&, const String&);
  • trunk/Source/WebKit2/ChangeLog

    r215801 r215807  
     12017-04-25  Alex Christensen  <achristensen@webkit.org>
     2
     3        Encoded filename should be decoded for WKContentExtension.identifier
     4        https://bugs.webkit.org/show_bug.cgi?id=171316
     5
     6        Reviewed by Andy Estes.
     7
     8        * UIProcess/API/APIContentExtensionStore.cpp:
     9        (API::createExtension):
     10        (API::ContentExtensionStore::lookupContentExtension):
     11        (API::ContentExtensionStore::getAvailableContentExtensionIdentifiers):
     12
    1132017-04-26  Andrew Gold  <agold@apple.com>
    214
  • trunk/Source/WebKit2/UIProcess/API/APIContentExtensionStore.cpp

    r215209 r215807  
    335335}
    336336
    337 static RefPtr<API::ContentExtension> createExtension(const String& identifier, const ContentExtensionMetaData& metaData, const Data& fileData)
     337static Ref<API::ContentExtension> createExtension(const String& identifier, const ContentExtensionMetaData& metaData, const Data& fileData)
    338338{
    339339    auto sharedMemory = WebKit::SharedMemory::create(const_cast<uint8_t*>(fileData.data()), fileData.size(), WebKit::SharedMemory::Protection::ReadOnly);
     
    384384       
    385385        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), identifier = WTFMove(identifier), fileData = WTFMove(fileData), metaData = WTFMove(metaData), completionHandler = WTFMove(completionHandler)] {
    386             RefPtr<API::ContentExtension> contentExtension = createExtension(identifier, metaData, fileData);
    387             completionHandler(contentExtension, { });
     386            completionHandler(createExtension(identifier, metaData, fileData), { });
    388387        });
    389388    });
     
    399398        const auto prefixLength = constructedPathPrefix().length();
    400399        for (const auto& path : fullPaths)
    401             identifiers.uncheckedAppend(path.substring(path.reverseFind('/') + 1 + prefixLength));
     400            identifiers.uncheckedAppend(WebCore::decodeFromFilename(path.substring(path.reverseFind('/') + 1 + prefixLength)));
    402401
    403402        RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), identifiers = WTFMove(identifiers)]() mutable {
  • trunk/Tools/ChangeLog

    r215790 r215807  
     12017-04-25  Alex Christensen  <achristensen@webkit.org>
     2
     3        Encoded filename should be decoded for WKContentExtension.identifier
     4        https://bugs.webkit.org/show_bug.cgi?id=171316
     5
     6        Reviewed by Andy Estes.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKit2Cocoa/WKContentExtensionStore.mm: Copied from Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm.
     10        (TEST_F):
     11        * TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm: Removed.
     12
    1132017-04-25  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r215790 r215807  
    204204                5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */; };
    205205                5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */; };
    206                 5CE354D91E70DA5C00BEFE3B /* WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKUserContentExtensionStore.mm */; };
     206                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
    207207                5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */; };
    208208                631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; };
     
    11531153                5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ApplicationCache.db-shm"; sourceTree = "<group>"; };
    11541154                5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "ApplicationCache.db-wal"; sourceTree = "<group>"; };
    1155                 5CE354D81E70D9C300BEFE3B /* WKUserContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKUserContentExtensionStore.mm; sourceTree = "<group>"; };
     1155                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
    11561156                5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegateCrash.mm; path = ../ios/WKScrollViewDelegateCrash.mm; sourceTree = "<group>"; };
    11571157                631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = "<group>"; };
     
    17451745                                5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */,
    17461746                                51C683DD1EA134DB00650183 /* WKURLSchemeHandler-1.mm */,
    1747                                 5CE354D81E70D9C300BEFE3B /* WKUserContentExtensionStore.mm */,
     1747                                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */,
    17481748                                2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */,
    17491749                                7C417F311D19E14800B8EF53 /* WKWebViewDefaultNavigationDelegate.mm */,
     
    30543054                                5C7964101EB0278D0075D74C /* EventModifiers.cpp in Sources */,
    30553055                                2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */,
    3056                                 5CE354D91E70DA5C00BEFE3B /* WKUserContentExtensionStore.mm in Sources */,
     3056                                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */,
    30573057                                2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */,
    30583058                                A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKContentExtensionStore.mm

    r215806 r215807  
    105105}
    106106
     107TEST_F(WKContentExtensionStoreTest, EncodedIdentifier)
     108{
     109    // FIXME: U+00C4 causes problems here. Using the output of encodeForFileName with
     110    // the filesystem changes it to U+0041 followed by U+0308
     111    NSString *identifier = @":;%25%+25И😍";
     112    __block bool done = false;
     113    [[WKContentExtensionStore defaultStore] compileContentExtensionForIdentifier:identifier encodedContentExtension:basicFilter completionHandler:^(WKContentExtension *filter, NSError *error) {
     114
     115        EXPECT_STREQ(filter.identifier.UTF8String, identifier.UTF8String);
     116
     117        [[WKContentExtensionStore defaultStore] getAvailableContentExtensionIdentifiers:^(NSArray<NSString *> *identifiers) {
     118            EXPECT_EQ(identifiers.count, 1u);
     119            EXPECT_EQ(identifiers[0].length, identifier.length);
     120            EXPECT_STREQ(identifiers[0].UTF8String, identifier.UTF8String);
     121
     122            done = true;
     123        }];
     124    }];
     125    TestWebKitAPI::Util::run(&done);
     126}
     127
    107128TEST_F(WKContentExtensionStoreTest, NonExistingIdentifierLookup)
    108129{
Note: See TracChangeset for help on using the changeset viewer.