mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
FIx for validating mbox format
Added email validator and code for checking if a file is mbox format or not
This commit is contained in:
parent
7995fbd577
commit
766e78c208
@ -5,6 +5,7 @@ file.reference.commons-lang3-3.8.1.jar=release/modules/ext/commons-lang3-3.8.1.j
|
||||
file.reference.apache-mime4j-core-0.8.0.jar=release/modules/ext/apache-mime4j-core-0.8.0-SNAPSHOT.jar
|
||||
file.reference.apache-mime4j-dom-0.8.0.jar=release/modules/ext/apache-mime4j-dom-0.8.0-SNAPSHOT.jar
|
||||
file.reference.apache-mime4j-mbox-iterator-0.8.0.jar=release/modules/ext/apache-mime4j-mbox-iterator-0.8.0-SNAPSHOT.jar
|
||||
file.reference.commons-validator-1.6.jar=release/modules/ext/commons-validator-1.6.jar
|
||||
file.reference.guava-19.0.jar=release/modules/ext/guava-19.0.jar
|
||||
file.reference.java-libpst-1.0-SNAPSHOT.jar=release/modules/ext/java-libpst-1.0-SNAPSHOT.jar
|
||||
file.reference.ez-vcard-0.10.5.jar=release/modules/ext/ez-vcard-0.10.5.jar
|
||||
|
@ -100,6 +100,10 @@
|
||||
<runtime-relative-path>ext/vinnie-2.0.2.jar</runtime-relative-path>
|
||||
<binary-origin>release/modules/ext/vinnie-2.0.2.jar</binary-origin>
|
||||
</class-path-extension>
|
||||
<class-path-extension>
|
||||
<runtime-relative-path>ext/commons-validator-1.6.jar</runtime-relative-path>
|
||||
<binary-origin>release/modules/ext/commons-validator-1.6.jar</binary-origin>
|
||||
</class-path-extension>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
|
@ -40,6 +40,7 @@ import org.apache.james.mime4j.mboxiterator.CharBufferWrapper;
|
||||
import org.apache.james.mime4j.mboxiterator.MboxIterator;
|
||||
import org.apache.tika.parser.txt.CharsetDetector;
|
||||
import org.apache.tika.parser.txt.CharsetMatch;
|
||||
import org.apache.commons.validator.routines.EmailValidator;
|
||||
import org.openide.util.NbBundle;
|
||||
|
||||
/**
|
||||
@ -56,7 +57,13 @@ class MboxParser extends MimeJ4MessageParser implements Iterator<EmailMessage> {
|
||||
}
|
||||
|
||||
static boolean isValidMimeTypeMbox(byte[] buffer) {
|
||||
return (new String(buffer)).startsWith("From "); //NON-NLS
|
||||
String mboxHeaderLine = new String(buffer);
|
||||
if (mboxHeaderLine.startsWith("From ")) {
|
||||
String[] mboxLineValues = mboxHeaderLine.split(" ");
|
||||
EmailValidator validator = EmailValidator.getInstance(true, true);
|
||||
return validator.isValid(mboxLineValues[1]);
|
||||
}
|
||||
return false; //NON-NLS
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user