Merge pull request #5825 from jonas-koeritz/hashset-comments

Added the possibility to include a comment when adding hashes to a hash set
This commit is contained in:
Richard Cordovano 2020-04-28 09:58:24 -04:00 committed by GitHub
commit 77a295cb67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,7 @@ public class AddHashValuesToDatabaseProgressDialog extends javax.swing.JDialog {
display(parent); display(parent);
this.hashes = new ArrayList<>(); this.hashes = new ArrayList<>();
this.invalidHashes = new ArrayList<>(); this.invalidHashes = new ArrayList<>();
this.md5Pattern = Pattern.compile("^[a-fA-F0-9]{32}$"); // NON-NLS this.md5Pattern = Pattern.compile("^([a-fA-F0-9]{32})"); // NON-NLS
this.parentRef = parent; this.parentRef = parent;
this.hashDb = hashDb; this.hashDb = hashDb;
this.text = text; this.text = text;
@ -163,8 +163,14 @@ public class AddHashValuesToDatabaseProgressDialog extends javax.swing.JDialog {
hashEntry = hashEntry.trim(); hashEntry = hashEntry.trim();
Matcher m = md5Pattern.matcher(hashEntry); Matcher m = md5Pattern.matcher(hashEntry);
if (m.find()) { if (m.find()) {
// Is there any text left on this line? If so, treat it as a comment.
final String comment = hashEntry.substring(m.end()).trim();
if (comment.length() > 0) {
hashes.add(new HashEntry(null, m.group(0), null, null, comment));
} else {
// more information can be added to the HashEntry - sha-1, sha-512, comment // more information can be added to the HashEntry - sha-1, sha-512, comment
hashes.add(new HashEntry(null, m.group(0), null, null, null)); hashes.add(new HashEntry(null, m.group(0), null, null, null));
}
} else { } else {
if (!hashEntry.isEmpty()) { if (!hashEntry.isEmpty()) {
invalidHashes.add(hashEntry); invalidHashes.add(hashEntry);