mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-16 17:57:43 +00:00
escape the keyword in the same way we escape the text so that they will actually match
This commit is contained in:
parent
72d57a2b4c
commit
38b103f8cc
@ -468,10 +468,13 @@ class HighlightedText implements IndexedText {
|
||||
|
||||
StringBuilder highlightedText = new StringBuilder("");
|
||||
|
||||
//do a highlighting pass for each keyword
|
||||
for (String keyword : keywords) {
|
||||
//we also need to escape the keyword so that it matches the escpared text
|
||||
final String escapedKeyword = StringEscapeUtils.escapeHtml(keyword);
|
||||
int textOffset = 0;
|
||||
int hitOffset;
|
||||
while ((hitOffset = StringUtils.indexOfIgnoreCase(text, keyword, textOffset)) != -1) {
|
||||
while ((hitOffset = StringUtils.indexOfIgnoreCase(text, escapedKeyword, textOffset)) != -1) {
|
||||
// Append the portion of text up to (but not including) the hit.
|
||||
highlightedText.append(text.substring(textOffset, hitOffset));
|
||||
// Add in the highlighting around the keyword.
|
||||
@ -480,15 +483,15 @@ class HighlightedText implements IndexedText {
|
||||
highlightedText.append(HIGHLIGHT_POST);
|
||||
|
||||
// Advance the text offset past the keyword.
|
||||
textOffset = hitOffset + keyword.length();
|
||||
textOffset = hitOffset + escapedKeyword.length();
|
||||
}
|
||||
// Append the remainder of text field
|
||||
highlightedText.append(text.substring(textOffset, text.length()));
|
||||
if (highlightedText.length() > 0) {
|
||||
|
||||
} else {
|
||||
if (highlightedText.length() == 0) {
|
||||
return NbBundle.getMessage(HighlightedText.class, "HighlightedMatchesSource.getMarkup.noMatchMsg");
|
||||
}
|
||||
//reset for next pass
|
||||
text = highlightedText.toString();
|
||||
highlightedText = new StringBuilder("");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user