keyword search - change attribute ordering, cleanup escaping (now done in BB), do not write selector attribute (should go to gen info)

This commit is contained in:
adam-m 2012-03-23 12:06:46 -04:00
parent dd6222da75
commit 8f101145e2
2 changed files with 8 additions and 11 deletions

View File

@ -131,10 +131,7 @@ public class KeywordSearchUtil {
//TODO escaping should be handled by blackboard //TODO escaping should be handled by blackboard
public static String escapeForBlackBoard(String text) { public static String escapeForBlackBoard(String text) {
try { try {
//text = text.replaceAll("\\\\'", URLEncoder.encode("\\'", "UTF-8"));
text = text.replaceAll("'", URLEncoder.encode("'", "UTF-8")); text = text.replaceAll("'", URLEncoder.encode("'", "UTF-8"));
//text = text.replaceAll("\"", URLEncoder.encode("\"", "UTF-8"));
//text = text.replaceAll("\\\\", URLEncoder.encode("\\", "UTF-8"));
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
} }
return text; return text;

View File

@ -195,12 +195,9 @@ public class TermComponentQuery implements KeywordSearchQuery {
continue; continue;
} }
//regex keyword, escape and store
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID(), MODULE_NAME, "", KeywordSearchUtil.escapeForBlackBoard(termsQuery)));
//regex match //regex match
final String regexMatchEscaped = KeywordSearchUtil.escapeForBlackBoard(regexMatch); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID(), MODULE_NAME, "", regexMatch));
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD.getTypeID(), MODULE_NAME, "", regexMatchEscaped));
//list //list
if (listName == null) { if (listName == null) {
listName = ""; listName = "";
@ -208,17 +205,20 @@ public class TermComponentQuery implements KeywordSearchQuery {
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_SET.getTypeID(), MODULE_NAME, "", listName)); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_SET.getTypeID(), MODULE_NAME, "", listName));
//preview //preview
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW.getTypeID(), MODULE_NAME, "", KeywordSearchUtil.escapeForBlackBoard(snippet))); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_PREVIEW.getTypeID(), MODULE_NAME, "", snippet));
//regex keyword
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID(), MODULE_NAME, "", termsQuery));
//selector //selector TODO move to general info artifact
/*
if (keywordQuery != null) { if (keywordQuery != null) {
BlackboardAttribute.ATTRIBUTE_TYPE selType = keywordQuery.getType(); BlackboardAttribute.ATTRIBUTE_TYPE selType = keywordQuery.getType();
if (selType != null) { if (selType != null) {
BlackboardAttribute selAttr = new BlackboardAttribute(selType.getTypeID(), MODULE_NAME, "", regexMatchEscaped); BlackboardAttribute selAttr = new BlackboardAttribute(selType.getTypeID(), MODULE_NAME, "", regexMatch);
attributes.add(selAttr); attributes.add(selAttr);
} }
} } */
try { try {
bba.addAttributes(attributes); bba.addAttributes(attributes);