mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Disallowed commas and semicolons as potential characters in tag names
This commit is contained in:
parent
d06aab3532
commit
ac1b28ebe3
@ -42,7 +42,7 @@ GetTagNameDialog.createTag=Create Tag
|
|||||||
GetTagNameDialog.cancelName=Cancel
|
GetTagNameDialog.cancelName=Cancel
|
||||||
GetTagNameDialog.mustSupplyTtagName.msg=Must supply a tag name to continue.
|
GetTagNameDialog.mustSupplyTtagName.msg=Must supply a tag name to continue.
|
||||||
GetTagNameDialog.tagNameErr=Tag Name
|
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.illegalCharsErr=Illegal Characters
|
||||||
GetTagNameDialog.unableToAddTagNameToCase.msg=Unable to add the {0} tag name to the case.
|
GetTagNameDialog.unableToAddTagNameToCase.msg=Unable to add the {0} tag name to the case.
|
||||||
GetTagNameDialog.taggingErr=Tagging Error
|
GetTagNameDialog.taggingErr=Tagging Error
|
||||||
|
@ -122,17 +122,6 @@ public class GetTagNameDialog extends JDialog {
|
|||||||
setVisible(true);
|
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 class TagsTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private final ArrayList<TagName> tagNames = new ArrayList<>();
|
private final ArrayList<TagName> tagNames = new ArrayList<>();
|
||||||
@ -305,7 +294,7 @@ public class GetTagNameDialog extends JDialog {
|
|||||||
"GetTagNameDialog.mustSupplyTtagName.msg"),
|
"GetTagNameDialog.mustSupplyTtagName.msg"),
|
||||||
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.tagNameErr"),
|
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.tagNameErr"),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
} else if (containsIllegalCharacters(tagDisplayName)) {
|
} else if (TagsManager.containsIllegalCharacters(tagDisplayName)) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalChars.msg"),
|
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalChars.msg"),
|
||||||
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalCharsErr"),
|
NbBundle.getMessage(this.getClass(), "GetTagNameDialog.illegalCharsErr"),
|
||||||
|
@ -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.
|
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}
|
Blackboard.unableToIndexArtifact.error.msg=Unable to index blackboard artifact {0}
|
||||||
TagsManagerOptionsPanel.addTagNameButton.empty=Tag name text is empty.
|
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.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.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:
|
TagsManagerOptionsPanel.tagNamesListLabel.text=Your tag names:
|
||||||
|
@ -143,7 +143,7 @@ public class TagsManager implements Closeable {
|
|||||||
* @return A TagName data transfer object (DTO) representing the new tag
|
* @return A TagName data transfer object (DTO) representing the new tag
|
||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* @throws TagNameAlreadyExistsException If the tag name would be a
|
* @throws TagNameAlreadyExistsException If the tag name would be a
|
||||||
* duplicate.
|
* duplicate.
|
||||||
* @throws TskCoreException If there is an error adding the tag
|
* @throws TskCoreException If there is an error adding the tag
|
||||||
* to the case database.
|
* to the case database.
|
||||||
@ -164,7 +164,7 @@ public class TagsManager implements Closeable {
|
|||||||
* @return A TagName data transfer object (DTO) representing the new tag
|
* @return A TagName data transfer object (DTO) representing the new tag
|
||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* @throws TagNameAlreadyExistsException If the tag name would be a
|
* @throws TagNameAlreadyExistsException If the tag name would be a
|
||||||
* duplicate.
|
* duplicate.
|
||||||
* @throws TskCoreException If there is an error adding the tag
|
* @throws TskCoreException If there is an error adding the tag
|
||||||
* to the case database.
|
* to the case database.
|
||||||
@ -186,7 +186,7 @@ public class TagsManager implements Closeable {
|
|||||||
* @return A TagName data transfer object (DTO) representing the new tag
|
* @return A TagName data transfer object (DTO) representing the new tag
|
||||||
* name.
|
* name.
|
||||||
*
|
*
|
||||||
* @throws TagNameAlreadyExistsException If the tag name would be a
|
* @throws TagNameAlreadyExistsException If the tag name would be a
|
||||||
* duplicate.
|
* duplicate.
|
||||||
* @throws TskCoreException If there is an error adding the tag
|
* @throws TskCoreException If there is an error adding the tag
|
||||||
* to the case database.
|
* to the case database.
|
||||||
@ -195,6 +195,7 @@ public class TagsManager implements Closeable {
|
|||||||
if (null == caseDb) {
|
if (null == caseDb) {
|
||||||
throw new TskCoreException("Tags manager has been closed");
|
throw new TskCoreException("Tags manager has been closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
lazyLoadExistingTagNames();
|
lazyLoadExistingTagNames();
|
||||||
|
|
||||||
//The tag name already exists in the database, user either
|
//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);
|
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.
|
* 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.
|
* 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 {
|
public static class TagNameDoesNotExistException extends Exception {
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import java.util.TreeSet;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.DefaultListModel;
|
import javax.swing.DefaultListModel;
|
||||||
import org.netbeans.spi.options.OptionsPanelController;
|
import org.netbeans.spi.options.OptionsPanelController;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
import org.sleuthkit.autopsy.corecomponents.OptionsPanel;
|
||||||
@ -49,7 +50,7 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio
|
|||||||
tagNamesListModel = new DefaultListModel<>();
|
tagNamesListModel = new DefaultListModel<>();
|
||||||
tagNamesList.setModel(tagNamesListModel);
|
tagNamesList.setModel(tagNamesListModel);
|
||||||
tagNames = getTagNamesFromTagsSettings();
|
tagNames = getTagNamesFromTagsSettings();
|
||||||
newDisplayNames = new ArrayList<String>();
|
newDisplayNames = new ArrayList<>();
|
||||||
|
|
||||||
userTagNameTextField.setText("");
|
userTagNameTextField.setText("");
|
||||||
tagNameErrLabel.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"));
|
tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.empty"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (newDisplayName.contains(",") || newDisplayName.contains(";")) {
|
if (TagsManager.containsIllegalCharacters(newDisplayName)) {
|
||||||
tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.containCommaSemicolon"));
|
tagNameErrLabel.setText(NbBundle.getMessage(TagsManagerOptionsPanel.class, "TagsManagerOptionsPanel.addTagNameButton.containInvalidCharacter"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +282,8 @@ public class TagsManagerOptionsPanel extends javax.swing.JPanel implements Optio
|
|||||||
tagNamesList.setSelectedIndex(0);
|
tagNamesList.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newDisplayNames.remove(tagName.getDisplayName());
|
||||||
|
|
||||||
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_deleteTagNameButtonActionPerformed
|
}//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
|
* @return A string representation of the tag name in the format that is
|
||||||
* the properties file.
|
* used by the properties file.
|
||||||
*/
|
*/
|
||||||
public String toSettingsFormat() {
|
public String toSettingsFormat() {
|
||||||
return displayName + "," + description + "," + colorName;
|
return displayName + "," + description + "," + colorName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user