diff --git a/bindings/java/src/org/sleuthkit/datamodel/CommunicationsManager.java b/bindings/java/src/org/sleuthkit/datamodel/CommunicationsManager.java index 63540360ae8b3f0c8ada3c5dd8958286baff816d..4fefb10606bb1f8cb59694f35222527d843212a3 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CommunicationsManager.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CommunicationsManager.java @@ -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 diff --git a/bindings/java/src/org/sleuthkit/datamodel/CommunicationsUtils.java b/bindings/java/src/org/sleuthkit/datamodel/CommunicationsUtils.java index b5b784c128751fe11ea450dd5fdbabb8343e28d8..2484b1e16babe1bd61b1b0fe5fcb450b45855555 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/CommunicationsUtils.java +++ b/bindings/java/src/org/sleuthkit/datamodel/CommunicationsUtils.java @@ -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; }