diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-03-22 17:19:05 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-03-22 17:57:44 -0700 |
commit | ae3ccfd07e149d56c8ed3ce3faf7d89fd434f235 (patch) | |
tree | ae4b5d0d616008d261bc225d62240fb8170454d1 /src/com/android/settings/ProxySelector.java | |
parent | 24d6195266848c20cb0e2b0a737b9c2871f68346 (diff) | |
download | packages_apps_settings-ae3ccfd07e149d56c8ed3ce3faf7d89fd434f235.zip packages_apps_settings-ae3ccfd07e149d56c8ed3ce3faf7d89fd434f235.tar.gz packages_apps_settings-ae3ccfd07e149d56c8ed3ce3faf7d89fd434f235.tar.bz2 |
Fix ANR with bypass proxy regex
Bug: 4148297
Change-Id: I5519ed297acabb65e1992c65e4b4110380983bb1
Diffstat (limited to 'src/com/android/settings/ProxySelector.java')
-rw-r--r-- | src/com/android/settings/ProxySelector.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/com/android/settings/ProxySelector.java b/src/com/android/settings/ProxySelector.java index bdb32e3..909496e 100644 --- a/src/com/android/settings/ProxySelector.java +++ b/src/com/android/settings/ProxySelector.java @@ -62,13 +62,12 @@ public class ProxySelector extends Fragment implements DialogCreatable { private static final String HOSTNAME_REGEXP = "^$|^[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*)*$"; private static final Pattern HOSTNAME_PATTERN; - private static final String EXCLLIST_REGEXP = - "$|^(.?[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*)*)+" + - "(,(.?[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*)*))*$"; - private static final Pattern EXCLLIST_PATTERN; + private static final String EXCLUSION_REGEXP = + "$|^(.?[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]+(\\-[a-zA-Z0-9]+)*)*)+$"; + private static final Pattern EXCLUSION_PATTERN; static { HOSTNAME_PATTERN = Pattern.compile(HOSTNAME_REGEXP); - EXCLLIST_PATTERN = Pattern.compile(EXCLLIST_REGEXP); + EXCLUSION_PATTERN = Pattern.compile(EXCLUSION_REGEXP); } private static final int ERROR_DIALOG_ID = 0; @@ -201,11 +200,14 @@ public class ProxySelector extends Fragment implements DialogCreatable { */ public static int validate(String hostname, String port, String exclList) { Matcher match = HOSTNAME_PATTERN.matcher(hostname); - Matcher listMatch = EXCLLIST_PATTERN.matcher(exclList); + String exclListArray[] = exclList.split(","); if (!match.matches()) return R.string.proxy_error_invalid_host; - if (!listMatch.matches()) return R.string.proxy_error_invalid_exclusion_list; + for (String excl : exclListArray) { + Matcher m = EXCLUSION_PATTERN.matcher(excl); + if (!m.matches()) return R.string.proxy_error_invalid_exclusion_list; + } if (hostname.length() > 0 && port.length() == 0) { return R.string.proxy_error_empty_port; |