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
1 changed files with 2 additions and 4 deletions

View File

@ -108,15 +108,13 @@ public class Utility {
public static boolean domainFieldValid(EditText view) {
if (view.getText() != null) {
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;
}
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;
}
if ((s.equalsIgnoreCase("localhost")) || (s.equalsIgnoreCase("localhost.localdomain"))) {
return true;
}
}
return false;
}