You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Achim Staebler (JIRA)" <ji...@apache.org> on 2015/02/20 10:57:11 UTC

[jira] [Created] (CB-8518) InAppBrowser fails to open external urls in system browser (naive fix included)

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: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org