@@ -133,6 +133,7 @@ public class InAppBrowser extends CordovaPlugin {
133
133
private boolean hideUrlBar = false ;
134
134
private boolean showFooter = false ;
135
135
private String footerColor = "" ;
136
+ private String [] allowedSchemes ;
136
137
137
138
/**
138
139
* Executes the request and returns PluginResult.
@@ -1110,6 +1111,29 @@ else if (url.startsWith("sms:")) {
1110
1111
LOG .e (LOG_TAG , "Error sending sms " + url + ":" + e .toString ());
1111
1112
}
1112
1113
}
1114
+ // Test for whitelisted custom scheme names like mycoolapp:// or twitteroauthresponse:// (Twitter Oauth Response)
1115
+ else if (!url .startsWith ("http:" ) && !url .startsWith ("https:" ) && url .matches ("^[a-z]*://.*?$" )) {
1116
+ if (allowedSchemes == null ) {
1117
+ String allowed = preferences .getString ("AllowedSchemes" , "" );
1118
+ allowedSchemes = allowed .split ("," );
1119
+ }
1120
+ if (allowedSchemes != null ) {
1121
+ for (String scheme : allowedSchemes ) {
1122
+ if (url .startsWith (scheme )) {
1123
+ try {
1124
+ JSONObject obj = new JSONObject ();
1125
+ obj .put ("type" , "customscheme" );
1126
+ obj .put ("url" , url );
1127
+ sendUpdate (obj , true );
1128
+ return true ;
1129
+ } catch (JSONException ex ) {
1130
+ LOG .e (LOG_TAG , "Custom Scheme URI passed in has caused a JSON error." );
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+
1113
1137
return false ;
1114
1138
}
1115
1139
@@ -1232,4 +1256,4 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
1232
1256
super .onReceivedHttpAuthRequest (view , handler , host , realm );
1233
1257
}
1234
1258
}
1235
- }
1259
+ }
0 commit comments