Ghidra is a software reverse engineering (SRE) framework
GP-3004 - Fixed bug in Table Column Filter that prevented the preview from working if the matching text contained HTML.
dragonmacher8e0db744e749
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/constrainteditor/AutocompletingStringConstraintEditor.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/constrainteditor/AutocompletingStringConstraintEditor.javaindex fdf607b482..860cc32102 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/constrainteditor/AutocompletingStringConstraintEditor.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/constrainteditor/AutocompletingStringConstraintEditor.java@@ -214,20 +214,41 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintEprivate String formatListValue(String value, boolean isSelected) {+ //+ // We format the matching part of the given value by using HTML to highlight the match.+ // Since we use HTML, any HTML inside of value will interfere with the HTML we add here.+ // To prevent this interference, we must escape the HTML inside of value.+ //++ // Rebuild the content by collecting all parts of the string, matching and non-matching.+ // Normally we would use the matcher to append content to the string buffer, but that+ // prevents us from being able to fix the HTML at the right time.Matcher matcher = model.lastConstraint.getHighlightMatcher(value);Color color = isSelected ? Palette.YELLOW : Palette.MAGENTA;StringBuilder sb = new StringBuilder("<html>");++ int start = 0;+// find and highlight all instances of the user-defined patternwhile (matcher.find()) {+String group = matcher.group(1);+ int nextStart = matcher.start();+ String previousText = value.substring(start, nextStart);+ start = matcher.end();+ sb.append(HTMLUtilities.escapeHTML(previousText));// escape all unescaped '\' and '$' chars, as Match.appendReplacement() will treat// them as regex charactersString quoted = Matcher.quoteReplacement(group);- String replacement = HTMLUtilities.colorString(color, HTMLUtilities.bold(quoted));- matcher.appendReplacement(sb, replacement);+ String escaped = HTMLUtilities.escapeHTML(quoted);+ String replacement = HTMLUtilities.colorString(color, HTMLUtilities.bold(escaped));+ sb.append(replacement);}- matcher.appendTail(sb);++ String trailing = value.substring(start, value.length());+ sb.append(HTMLUtilities.escapeHTML(trailing));+return sb.toString();}@@ -237,7 +258,6 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintEsuper.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);String valueString = formatListValue(value, isSelected);-setText(valueString);return this;}