Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14048

Inappbrowser allowedSchemes doesn't check empty string

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      The new AllowSchemes introduced with inappbrowser@3.0.0 doesn't check if  AllowSchemes contains  empty string after having being loaded, respectively only if null, which could lead to error in case a custom scheme is use but not set as white listed schema 

      What I mean is that, if no preference would be set in config.xml but a custom scheme would be used (my case) then the variable allowSchemes won't be null but will contains an empty string

       

      In InAppBrowser.java

       

      else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^[a-z]*://.*?$")) {
          if (allowedSchemes == null) {
              String allowed = preferences.getString("AllowedSchemes", "");
              allowedSchemes = allowed.split(",");
          }
          if (allowedSchemes != null) { // <------- If  preference AllowedSchemes is not specified, variable allowedSchemes not gonna be null but an array containing an empty string
             for (String scheme : allowedSchemes) { 
                 if (url.startsWith(scheme)) { 
                    if (url.startsWith(scheme)) { // <------ which leads to the problem "urlidontwanttowhilelist://".startsWith("") == true

        

      I would like to improve this check for example like following

       

      if (url.startsWith(scheme) && !"".equals(scheme)) {
      
      

       

       Thx in advance for the improvement

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                reedrichards Reed Richards
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: