diff --git a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties index 71ce8a4504..ba828aed5d 100755 --- a/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/actions/Bundle.properties @@ -42,7 +42,7 @@ GetTagNameDialog.createTag=Create Tag GetTagNameDialog.cancelName=Cancel GetTagNameDialog.mustSupplyTtagName.msg=Must supply a tag name to continue. GetTagNameDialog.tagNameErr=Tag Name -GetTagNameDialog.illegalChars.msg=The tag name contains illegal characters.\nCannot contain any of the following symbols\: \\ \: * ? " < > | +GetTagNameDialog.illegalChars.msg=The tag name contains illegal characters.\nCannot contain any of the following symbols\: \\ \: * ? " < > | , ; GetTagNameDialog.illegalCharsErr=Illegal Characters GetTagNameDialog.unableToAddTagNameToCase.msg=Unable to add the {0} tag name to the case. GetTagNameDialog.taggingErr=Tagging Error diff --git a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java index b24f69d757..9f6f23282f 100644 --- a/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java +++ b/Core/src/org/sleuthkit/autopsy/actions/GetTagNameDialog.java @@ -122,17 +122,6 @@ public class GetTagNameDialog extends JDialog { setVisible(true); } - private boolean containsIllegalCharacters(String content) { - return (content.contains("\\") - || content.contains(":") - || content.contains("*") - || content.contains("?") - || content.contains("\"") - || content.contains("<") - || content.contains(">") - || content.contains("|")); - } - private class TagsTableModel extends AbstractTableModel { private final ArrayList tagNames = new ArrayList<>(); @@ -305,7 +294,7 @@ public class GetTagNameDialog extends JDialog { "GetTagNameDialog.mustSupplyTtagName.msg"), NbBundle.getMessage(this.getClass(), "GetTagNameDialog.tagNameErr"), JOptionPane.ERROR_MESSAGE); - } else if (containsIllegalCharacters(tagDisplayName)) { + } else if (TagsManager.containsIllegalCharacters(tagDisplayName)) { JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalChars.msg"), NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalCharsErr"), diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties index 638c8a8412..a7425bfa0d 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties @@ -10,7 +10,7 @@ TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to publish new blackbo TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to publish blackboard artifact tag deleted event. There is no case open. Blackboard.unableToIndexArtifact.error.msg=Unable to index blackboard artifact {0} TagsManagerOptionsPanel.addTagNameButton.empty=Tag name text is empty. -TagsManagerOptionsPanel.addTagNameButton.containCommaSemicolon=Tag name may not contain commas or semicolons. +TagsManagerOptionsPanel.addTagNameButton.containInvalidCharacter=Tag name may not contain any of the following symbols\: \\ \: * ? " < > | , ; TagsManagerOptionsPanel.addTagNameButton.alreadyExists=Tag name already exists. TagsManagerOptionsPanel.jLabel1.text=Autopsy keeps a list of the tag names you have created in the past. Add more or delete them here. TagsManagerOptionsPanel.tagNamesListLabel.text=Your tag names: diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java index e838e24c7b..6848f5cb0a 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManager.java @@ -143,7 +143,7 @@ public class TagsManager implements Closeable { * @return A TagName data transfer object (DTO) representing the new tag * name. * - * @throws TagNameAlreadyExistsException If the tag name would be a + * @throws TagNameAlreadyExistsException If the tag name would be a * duplicate. * @throws TskCoreException If there is an error adding the tag * to the case database. @@ -164,7 +164,7 @@ public class TagsManager implements Closeable { * @return A TagName data transfer object (DTO) representing the new tag * name. * - * @throws TagNameAlreadyExistsException If the tag name would be a + * @throws TagNameAlreadyExistsException If the tag name would be a * duplicate. * @throws TskCoreException If there is an error adding the tag * to the case database. @@ -186,7 +186,7 @@ public class TagsManager implements Closeable { * @return A TagName data transfer object (DTO) representing the new tag * name. * - * @throws TagNameAlreadyExistsException If the tag name would be a + * @throws TagNameAlreadyExistsException If the tag name would be a * duplicate. * @throws TskCoreException If there is an error adding the tag * to the case database. @@ -195,6 +195,7 @@ public class TagsManager implements Closeable { if (null == caseDb) { throw new TskCoreException("Tags manager has been closed"); } + lazyLoadExistingTagNames(); //The tag name already exists in the database, user either @@ -723,6 +724,26 @@ public class TagsManager implements Closeable { ModuleSettings.setConfigSetting(TAGS_SETTINGS_NAME, TAG_NAMES_SETTING_KEY, setting); } + /** + * Returns true if the tag display name contains an illegal character. Used + * after a tag display name is retrieved from user input. + * + * @param content Display name of the tag being added. + * @return boolean indicating whether the name has an invalid character. + */ + public static boolean containsIllegalCharacters(String content) { + return (content.contains("\\") + || content.contains(":") + || content.contains("*") + || content.contains("?") + || content.contains("\"") + || content.contains("<") + || content.contains(">") + || content.contains("|") + || content.contains(",") + || content.contains(";")); + } + /** * Exception thrown if there is an attempt to add a duplicate tag name. */ @@ -733,6 +754,7 @@ public class TagsManager implements Closeable { /** * Exception thrown if there is an attempt to delete a nonexistent tag name. + * Unused for current implementation of tag name deletion. */ public static class TagNameDoesNotExistException extends Exception { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManagerOptionsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManagerOptionsPanel.java index 37bec75390..f63059e85e 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManagerOptionsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/TagsManagerOptionsPanel.java @@ -14,6 +14,7 @@ import java.util.TreeSet; import java.util.logging.Level; import javax.swing.DefaultListModel; import org.netbeans.spi.options.OptionsPanelController; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.corecomponents.OptionsPanel; @@ -49,7 +50,7 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio tagNamesListModel = new DefaultListModel<>(); tagNamesList.setModel(tagNamesListModel); tagNames = getTagNamesFromTagsSettings(); - newDisplayNames = new ArrayList(); + newDisplayNames = new ArrayList<>(); userTagNameTextField.setText(""); tagNameErrLabel.setText(""); @@ -240,8 +241,8 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.empty")); return; } - if (newDisplayName.contains(",") || newDisplayName.contains(";")) { - tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.containCommaSemicolon")); + if (TagsManager.containsIllegalCharacters(newDisplayName)) { + tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.containInvalidCharacter")); return; } @@ -281,6 +282,8 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio tagNamesList.setSelectedIndex(0); } + newDisplayNames.remove(tagName.getDisplayName()); + firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null); } }//GEN-LAST:event_deleteTagNameButtonActionPerformed @@ -409,8 +412,8 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio } /** - * @return A String with of the tag name in the format that is used by - * the properties file. + * @return A string representation of the tag name in the format that is + * used by the properties file. */ public String toSettingsFormat() { return displayName + "," + description + "," + colorName;