Skip to content
Snippets Groups Projects
Commit afce680a authored by Raman Arora's avatar Raman Arora
Browse files

Addressed review comments.

parent f427ee5e
Branches
Tags
No related merge requests found
......@@ -332,12 +332,12 @@ public Account getAccount(org.sleuthkit.datamodel.Account.Type accountType, Stri
* instances and between all recipient account instances. All account
* instances must be from the same data source.
*
* @param sender sender account
* @param recipients list of recipients
* @param sourceArtifact Artifact that relationships were derived from
* @param relationshipType The type of relationships to be created
* @param sender Sender account, may be null.
* @param recipients List of recipients, may be empty.
* @param sourceArtifact Artifact that relationships were derived from.
* @param relationshipType The type of relationships to be created.
* @param dateTime Date of communications/relationship, as epoch
* seconds
* seconds.
*
*
* @throws org.sleuthkit.datamodel.TskCoreException
......
......@@ -140,16 +140,13 @@ public static boolean isValidPhoneNumber(String phoneNum) {
return false;
}
// short min length allows of dial codes.
if (phoneNum.length() < MIN_PHONENUMBER_LEN) {
return false;
}
String trimmedPhoneNum = phoneNum.trim();
// A phone number may have a leading '+', special telephony chars, or digits.
// Anything else implies an invalid phone number.
for (int i = 0; i < phoneNum.length(); i++) {
if (!((i == 0 && phoneNum.charAt(i) == '+')
|| isValidPhoneChar(phoneNum.charAt(i)))) {
for (int i = 0; i < trimmedPhoneNum.length(); i++) {
if (!((trimmedPhoneNum.charAt(i) == '+' && i == 0) // a '+' is allowed only at the beginning
|| isValidPhoneChar(trimmedPhoneNum.charAt(i)))) {
return false;
}
}
......@@ -157,6 +154,13 @@ public static boolean isValidPhoneNumber(String phoneNum) {
return true;
}
/**
* Checks if the given character is a valid character for a phone number.
*
* @param ch Character to check.
*
* @return True, if its a valid phone number character, false, otherwise.
*/
private static boolean isValidPhoneChar(char ch) {
return Character.isSpaceChar(ch)
|| Character.isDigit(ch)
......@@ -186,8 +190,7 @@ public static boolean isValidEmailAddress(String emailAddress) {
}
if (emailAddress.contains("@") == false
|| emailAddress.contains(".") == false
|| emailAddress.length() < 5) {
|| emailAddress.contains(".") == false ) {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment