Achim Staebler created CB-8518:
----------------------------------

             Summary: InAppBrowser fails to open external urls in system 
browser (naive fix included)
                 Key: CB-8518
                 URL: https://issues.apache.org/jira/browse/CB-8518
             Project: Apache Cordova
          Issue Type: Bug
          Components: Plugin InAppBrowser
    Affects Versions: 0.6.1
         Environment: ios 8.1, tested in ipad air emulator
            Reporter: Achim Staebler


Attempts to open an external url with

window.open("http://www.apache.org";, "_system");

fail silently. The root cause is line 91, where an absolute URL is constructed 
from the app's base URL and the url passed to window.open:

        NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] 
absoluteURL];

 However, cordova resources are served via file:// scheme, so absoluteURL will 
be nil in this case. My suggested fix compares the URL's schemes and skips 
creating a relative url when this clearly does not work:

NSURL* absoluteUrl;
        NSURL* urlTarget = [NSURL URLWithString:url];

        if ([urlTarget.scheme isEqualToString:baseUrl.scheme]) {
            // same protocol, can use relative URL Relative to base
            absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] 
absoluteURL];
        } else {
            absoluteUrl = urlTarget;
        }

I'm not submitting this as a pull request because I'm not certain about the 
portential security implications this native fix might have.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to