Skip to content
  • aestes@apple.com's avatar
    [WebKit2] REGRESSION (Custom Protocols): Reproducible crash when navigating to... · 4fa77596
    aestes@apple.com authored
    [WebKit2] REGRESSION (Custom Protocols): Reproducible crash when navigating to URL with an invalid scheme
    https://bugs.webkit.org/show_bug.cgi?id=115790
    
    Reviewed by Alexey Proskuryakov.
    
    Source/WebKit2:
    
    NSMutableSet does not support adding or removing nil objects, and
    WTF::HashSet does not support adding, removing, or checking for null
    WTF::Strings.
    
    For the NSMutableSet case, make sure that we don't try to add or remove
    nil NSStrings.
    
    For the WTF::HashSet case, NSURL will return a nil NSString if we ask
    it for its scheme when it is invalid, which we will convert to a null
    WTF::String. Don't try to check if our HashSet of registered schemes
    contains a null String.
    
    * Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm:
    (WebKit::CustomProtocolManager::registerScheme): Assert that the scheme
    isn't null. We reject null schemes at the WKBrowsingContextController level.
    (WebKit::CustomProtocolManager::unregisterScheme): Ditto.
    (WebKit::CustomProtocolManager::supportsScheme): If scheme is null, return false.
    * UIProcess/API/mac/WKBrowsingContextController.mm:
    (+[WKBrowsingContextController registerSchemeForCustomProtocol:]): Do not register a nil scheme.
    (+[WKBrowsingContextController unregisterSchemeForCustomProtocol:]): Ditto.
    
    Tools:
    
    Added two API tests:
    
    1) Verify that +[WKBrowsingContextController (un)registerSchemeForCustomProtocol:] can be called with a nil NSString without crashing.
    2) Verify that +[WKCustomProtocol canInitWithRequest:] does not crash when passed an NSURLRequest with an invalid scheme.
    
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsInvalidScheme.mm: Added.
    (TestWebKitAPI):
    (TestWebKitAPI::TEST):
    * TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsInvalidScheme_Bundle.cpp: Added.
    (TestWebKitAPI):
    (TestWebKitAPI::decidePolicyForNavigationAction):
    (CustomProtocolInvalidSchemeTest):
    (TestWebKitAPI::CustomProtocolInvalidSchemeTest::CustomProtocolInvalidSchemeTest):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149774 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    4fa77596