diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java index 9aee14ede8..7b0b2eb30e 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/EmailMessage.java @@ -47,7 +47,7 @@ class EmailMessage { private long id = -1L; private String messageID = ""; private String inReplyToID = ""; - private String references = ""; + private List references = null; boolean hasAttachment() { return hasAttachment; @@ -226,7 +226,7 @@ class EmailMessage { * * @return reference list or empty string if non is available. */ - String getReferences() { + List getReferences() { return references; } @@ -235,7 +235,7 @@ class EmailMessage { * * @param references */ - void setReferences(String references) { + void setReferences(List references) { this.references = references; } diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java index 402a2090ec..f2294349c8 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/MboxParser.java @@ -181,14 +181,26 @@ class MboxParser { email.setLocalPath(localPath); email.setMessageID(msg.getMessageId()); - Field field = msg.getHeader().getField("in-reply-to"); //NON-NLS + Field field = msg.getHeader().getField("in-reply-to"); //NON-NLS + String inReplyTo = null; + if (field != null) { - email.setInReplyToID(field.getBody()); + inReplyTo = field.getBody(); + email.setInReplyToID(inReplyTo); } - + field = msg.getHeader().getField("references"); - if (field != null ) { - email.setReferences(field.getBody()); + if (field != null) { + List references = new ArrayList<>(); + for (String id : field.getBody().split(">")) { + references.add(id.trim() + ">"); + } + + if (!references.contains(inReplyTo)) { + references.add(inReplyTo); + } + + email.setReferences(references); } // Body diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java index 251d9b67d0..81d26b6609 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/PstParser.java @@ -193,13 +193,24 @@ class PstParser { email.setSubject(msg.getSubject()); email.setId(msg.getDescriptorNodeId()); email.setMessageID(msg.getInternetMessageId()); - email.setInReplyToID(msg.getInReplyToId()); + + String inReplyToID = msg.getInReplyToId(); + email.setInReplyToID(inReplyToID); if (msg.hasAttachments()) { extractAttachments(email, msg, fileID); } - email.setReferences(extractReferences(msg.getTransportMessageHeaders())); + List references = extractReferences(msg.getTransportMessageHeaders()); + if (inReplyToID != null && !inReplyToID.isEmpty()) { + if (references == null) { + references = new ArrayList<>(); + references.add(inReplyToID); + } else if (!references.contains(inReplyToID)) { + references.add(inReplyToID); + } + } + email.setReferences(references); return email; } @@ -349,28 +360,33 @@ class PstParser { /** * Returns the references value from the email header. - * + * * @param emailHeader - * @return + * + * @return A list of message-IDs */ - private String extractReferences( String emailHeader ){ + private List extractReferences(String emailHeader) { Scanner scanner = new Scanner(emailHeader); StringBuilder buffer = null; - while(scanner.hasNextLine()) { + while (scanner.hasNextLine()) { String token = scanner.nextLine(); - - if( token.matches("^References:.*") ) { + + if (token.matches("^References:.*")) { buffer = new StringBuilder(); - buffer.append((token.substring(token.indexOf(":")+1)).trim()); - } else if ( buffer != null ) { - if(token.matches("^\\w+:.*$")){ - return buffer.toString(); + buffer.append((token.substring(token.indexOf(":") + 1)).trim()); + } else if (buffer != null) { + if (token.matches("^\\w+:.*$")) { + List references = new ArrayList<>(); + for (String id : buffer.toString().split(">")) { + references.add(id.trim() + ">"); + } + return references; } else { buffer.append(token.trim()); } } } - - return ""; - } + + return null; + } }