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