mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Extend whitelist to handle URLs without // chars
This commit is contained in:
parent
c2cafb4b45
commit
955133f173
@ -124,15 +124,15 @@ public class Whitelist {
|
|||||||
whiteList = null;
|
whiteList = null;
|
||||||
}
|
}
|
||||||
else { // specific access
|
else { // specific access
|
||||||
Pattern parts = Pattern.compile("^((\\*|[A-Za-z-]+)://)?(\\*|((\\*\\.)?[^*/:]+))?(:(\\d+))?(/.*)?");
|
Pattern parts = Pattern.compile("^((\\*|[A-Za-z-]+):(//)?)?(\\*|((\\*\\.)?[^*/:]+))?(:(\\d+))?(/.*)?");
|
||||||
Matcher m = parts.matcher(origin);
|
Matcher m = parts.matcher(origin);
|
||||||
if (m.matches()) {
|
if (m.matches()) {
|
||||||
String scheme = m.group(2);
|
String scheme = m.group(2);
|
||||||
String host = m.group(3);
|
String host = m.group(4);
|
||||||
// Special case for two urls which are allowed to have empty hosts
|
// Special case for two urls which are allowed to have empty hosts
|
||||||
if (("file".equals(scheme) || "content".equals(scheme)) && host == null) host = "*";
|
if (("file".equals(scheme) || "content".equals(scheme)) && host == null) host = "*";
|
||||||
String port = m.group(7);
|
String port = m.group(8);
|
||||||
String path = m.group(8);
|
String path = m.group(9);
|
||||||
if (scheme == null) {
|
if (scheme == null) {
|
||||||
// XXX making it stupid friendly for people who forget to include protocol/SSL
|
// XXX making it stupid friendly for people who forget to include protocol/SSL
|
||||||
whiteList.add(new URLPattern("http", host, port, path));
|
whiteList.add(new URLPattern("http", host, port, path));
|
||||||
|
Loading…
Reference in New Issue
Block a user