Loading core/java/android/app/admin/DevicePolicyManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -1155,7 +1155,9 @@ public class DevicePolicyManager { } exclSpec = listBuilder.toString(); } android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec); if (android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec) != android.net.Proxy.PROXY_VALID) throw new IllegalArgumentException(); } return mService.setGlobalProxy(admin, hostSpec, exclSpec, UserHandle.myUserId()); } catch (RemoteException e) { Loading core/java/android/net/Proxy.java +21 −17 Original line number Diff line number Diff line Loading @@ -66,6 +66,19 @@ public final class Proxy { /** {@hide} **/ public static final String EXTRA_PROXY_INFO = "proxy"; /** @hide */ public static final int PROXY_VALID = 0; /** @hide */ public static final int PROXY_HOSTNAME_EMPTY = 1; /** @hide */ public static final int PROXY_HOSTNAME_INVALID = 2; /** @hide */ public static final int PROXY_PORT_EMPTY = 3; /** @hide */ public static final int PROXY_PORT_INVALID = 4; /** @hide */ public static final int PROXY_EXCLLIST_INVALID = 5; private static ConnectivityManager sConnectivityManager = null; // Hostname / IP REGEX validation Loading Loading @@ -236,36 +249,27 @@ public final class Proxy { * Validate syntax of hostname, port and exclusion list entries * {@hide} */ public static void validate(String hostname, String port, String exclList) { public static int validate(String hostname, String port, String exclList) { Matcher match = HOSTNAME_PATTERN.matcher(hostname); Matcher listMatch = EXCLLIST_PATTERN.matcher(exclList); if (!match.matches()) { throw new IllegalArgumentException(); } if (!match.matches()) return PROXY_HOSTNAME_INVALID; if (!listMatch.matches()) { throw new IllegalArgumentException(); } if (!listMatch.matches()) return PROXY_EXCLLIST_INVALID; if (hostname.length() > 0 && port.length() == 0) { throw new IllegalArgumentException(); } if (hostname.length() > 0 && port.length() == 0) return PROXY_PORT_EMPTY; if (port.length() > 0) { if (hostname.length() == 0) { throw new IllegalArgumentException(); } if (hostname.length() == 0) return PROXY_HOSTNAME_EMPTY; int portVal = -1; try { portVal = Integer.parseInt(port); } catch (NumberFormatException ex) { throw new IllegalArgumentException(); } if (portVal <= 0 || portVal > 0xFFFF) { throw new IllegalArgumentException(); return PROXY_PORT_INVALID; } if (portVal <= 0 || portVal > 0xFFFF) return PROXY_PORT_INVALID; } return PROXY_VALID; } static class AndroidProxySelectorRoutePlanner Loading core/java/android/net/ProxyProperties.java +3 −7 Original line number Diff line number Diff line Loading @@ -140,13 +140,9 @@ public class ProxyProperties implements Parcelable { public boolean isValid() { if (!TextUtils.isEmpty(mPacFileUrl)) return true; try { Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort), return Proxy.PROXY_VALID == Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort), mExclusionList == null ? "" : mExclusionList); } catch (IllegalArgumentException e) { return false; } return true; } public java.net.Proxy makeProxy() { Loading Loading
core/java/android/app/admin/DevicePolicyManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -1155,7 +1155,9 @@ public class DevicePolicyManager { } exclSpec = listBuilder.toString(); } android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec); if (android.net.Proxy.validate(hostName, Integer.toString(port), exclSpec) != android.net.Proxy.PROXY_VALID) throw new IllegalArgumentException(); } return mService.setGlobalProxy(admin, hostSpec, exclSpec, UserHandle.myUserId()); } catch (RemoteException e) { Loading
core/java/android/net/Proxy.java +21 −17 Original line number Diff line number Diff line Loading @@ -66,6 +66,19 @@ public final class Proxy { /** {@hide} **/ public static final String EXTRA_PROXY_INFO = "proxy"; /** @hide */ public static final int PROXY_VALID = 0; /** @hide */ public static final int PROXY_HOSTNAME_EMPTY = 1; /** @hide */ public static final int PROXY_HOSTNAME_INVALID = 2; /** @hide */ public static final int PROXY_PORT_EMPTY = 3; /** @hide */ public static final int PROXY_PORT_INVALID = 4; /** @hide */ public static final int PROXY_EXCLLIST_INVALID = 5; private static ConnectivityManager sConnectivityManager = null; // Hostname / IP REGEX validation Loading Loading @@ -236,36 +249,27 @@ public final class Proxy { * Validate syntax of hostname, port and exclusion list entries * {@hide} */ public static void validate(String hostname, String port, String exclList) { public static int validate(String hostname, String port, String exclList) { Matcher match = HOSTNAME_PATTERN.matcher(hostname); Matcher listMatch = EXCLLIST_PATTERN.matcher(exclList); if (!match.matches()) { throw new IllegalArgumentException(); } if (!match.matches()) return PROXY_HOSTNAME_INVALID; if (!listMatch.matches()) { throw new IllegalArgumentException(); } if (!listMatch.matches()) return PROXY_EXCLLIST_INVALID; if (hostname.length() > 0 && port.length() == 0) { throw new IllegalArgumentException(); } if (hostname.length() > 0 && port.length() == 0) return PROXY_PORT_EMPTY; if (port.length() > 0) { if (hostname.length() == 0) { throw new IllegalArgumentException(); } if (hostname.length() == 0) return PROXY_HOSTNAME_EMPTY; int portVal = -1; try { portVal = Integer.parseInt(port); } catch (NumberFormatException ex) { throw new IllegalArgumentException(); } if (portVal <= 0 || portVal > 0xFFFF) { throw new IllegalArgumentException(); return PROXY_PORT_INVALID; } if (portVal <= 0 || portVal > 0xFFFF) return PROXY_PORT_INVALID; } return PROXY_VALID; } static class AndroidProxySelectorRoutePlanner Loading
core/java/android/net/ProxyProperties.java +3 −7 Original line number Diff line number Diff line Loading @@ -140,13 +140,9 @@ public class ProxyProperties implements Parcelable { public boolean isValid() { if (!TextUtils.isEmpty(mPacFileUrl)) return true; try { Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort), return Proxy.PROXY_VALID == Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort), mExclusionList == null ? "" : mExclusionList); } catch (IllegalArgumentException e) { return false; } return true; } public java.net.Proxy makeProxy() { Loading