1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -05:00

Merge pull request #48 from rpimonitrbtch/master

Loosened the restrictions on the TLD to support custom private TLD's, as well as single label hostnames.

Resolves Issue 2784: Cannot set server hostname
This commit is contained in:
Jesse Vincent 2011-08-28 12:48:10 -07:00
commit a1378789b2

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;
}