1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-25 09:08:49 -05:00

Issue 2784: Cannot set server hostname

Loosened the restrictions on the TLD to support custom private TLD's, as well as single label hostnames. Removed the localhost and localhost.localdomain exceptions, as they are now redundant.
This commit is contained in:
rpimonitrbtch 2011-08-25 19:07:30 -03:00 committed by bellib
parent 91ef3b50f2
commit bdcb19e344

View File

@ -108,15 +108,13 @@ public class Utility {
public static boolean domainFieldValid(EditText view) { public static boolean domainFieldValid(EditText view) {
if (view.getText() != null) { if (view.getText() != null) {
String s = view.getText().toString(); String s = view.getText().toString();
if (s.matches("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$")) { if (s.matches("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)*[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?$") &&
s.length() <= 253) {
return true; return true;
} }
if (s.matches("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")) { if (s.matches("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")) {
return true; return true;
} }
if ((s.equalsIgnoreCase("localhost")) || (s.equalsIgnoreCase("localhost.localdomain"))) {
return true;
}
} }
return false; return false;
} }