mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-12 06:08:25 -05:00
Rewrote code to be easier to read and not raise a potential null pointer warning by Eclipse.
This commit is contained in:
parent
6a9a5f6b1f
commit
8f2623e33c
@ -84,36 +84,38 @@ public class DomainNameChecker
|
|||||||
*/
|
*/
|
||||||
private static boolean isIpAddress(String domain)
|
private static boolean isIpAddress(String domain)
|
||||||
{
|
{
|
||||||
boolean rval = ((domain != null) && (domain.length() != 0));
|
if ((domain == null) || (domain.length() == 0))
|
||||||
if (rval)
|
|
||||||
{
|
{
|
||||||
try
|
return false;
|
||||||
{
|
}
|
||||||
// do a quick-dirty IP match first to avoid DNS lookup
|
|
||||||
rval = QUICK_IP_PATTERN.matcher(domain).matches();
|
|
||||||
if (rval)
|
|
||||||
{
|
|
||||||
rval = domain.equals(InetAddress.getByName(domain)
|
|
||||||
.getHostAddress());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (UnknownHostException e)
|
|
||||||
{
|
|
||||||
String errorMessage = e.getMessage();
|
|
||||||
if (errorMessage == null)
|
|
||||||
{
|
|
||||||
errorMessage = "unknown host exception";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (K9.DEBUG)
|
boolean rval;
|
||||||
{
|
try
|
||||||
Log.v(K9.LOG_TAG, "DomainNameChecker.isIpAddress(): "
|
{
|
||||||
+ errorMessage);
|
// do a quick-dirty IP match first to avoid DNS lookup
|
||||||
}
|
rval = QUICK_IP_PATTERN.matcher(domain).matches();
|
||||||
|
if (rval)
|
||||||
rval = false;
|
{
|
||||||
|
rval = domain.equals(InetAddress.getByName(domain)
|
||||||
|
.getHostAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (UnknownHostException e)
|
||||||
|
{
|
||||||
|
String errorMessage = e.getMessage();
|
||||||
|
if (errorMessage == null)
|
||||||
|
{
|
||||||
|
errorMessage = "unknown host exception";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (K9.DEBUG)
|
||||||
|
{
|
||||||
|
Log.v(K9.LOG_TAG, "DomainNameChecker.isIpAddress(): "
|
||||||
|
+ errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
rval = false;
|
||||||
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user