Merge remote-tracking branch 'origin/patch'

Conflicts:
	Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/FileHeader.java
	Ghidra/Framework/Utility/src/main/java/ghidra/util/UserSearchUtils.java
This commit is contained in:
Ryan Kurtz 2022-07-15 09:58:09 -04:00
commit 7ccca377a7
2 changed files with 11 additions and 11 deletions

View file

@ -198,8 +198,8 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
} }
/** /**
* Cell renderer for suggestion nominees. Substrings that match the models' query * Cell renderer for suggestion candidates. Substrings that match the models' query are
* are highlighted for ease-of-use. * highlighted for ease-of-use.
*/ */
private class AutocompleteListCellRenderer extends GListCellRenderer<String> { private class AutocompleteListCellRenderer extends GListCellRenderer<String> {
@ -213,14 +213,17 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
private String formatListValue(String value, boolean isSelected) { private String formatListValue(String value, boolean isSelected) {
Matcher matcher = model.lastConstraint.getHighlightMatcher(value); Matcher matcher = model.lastConstraint.getHighlightMatcher(value);
Color color = isSelected ? Color.YELLOW : Color.MAGENTA; Color color = isSelected ? Color.YELLOW : Color.MAGENTA;
StringBuilder sb = new StringBuilder("<html>"); StringBuilder sb = new StringBuilder("<html>");
// find and highlight all instances of the user-defined pattern // find and highlight all instances of the user-defined pattern
while (matcher.find()) { while (matcher.find()) {
String group = matcher.group(1); String group = matcher.group(1);
String replacement = HTMLUtilities.colorString(color, HTMLUtilities.bold(group));
// escape all unescaped '\' and '$' chars, as Match.appendReplacement() will treat
// them as regex characters
String quoted = Matcher.quoteReplacement(group);
String replacement =
HTMLUtilities.colorString(color, HTMLUtilities.bold(quoted));
matcher.appendReplacement(sb, replacement); matcher.appendReplacement(sb, replacement);
} }
matcher.appendTail(sb); matcher.appendTail(sb);
@ -238,7 +241,5 @@ public class AutocompletingStringConstraintEditor extends DataLoadingConstraintE
setText(valueString); setText(valueString);
return this; return this;
} }
} }
} }

View file

@ -40,8 +40,7 @@ public class UserSearchUtils {
private final static char[] GLOB_CHARACTERS = { '*', '?' }; private final static char[] GLOB_CHARACTERS = { '*', '?' };
/** /**
* A pattern that will find all '\' chars that are not followed by '*', '?' * A pattern that will find all '\' chars that are not followed by '*', '?' or another '\'
* or another '\'
*/ */
public final static Pattern NON_GLOB_BACKSLASH_PATTERN = Pattern.compile("\\\\(?![\\*\\?])"); public final static Pattern NON_GLOB_BACKSLASH_PATTERN = Pattern.compile("\\\\(?![\\*\\?])");
@ -382,12 +381,12 @@ public class UserSearchUtils {
* array. * array.
* *
* @param input The input string to be escaped * @param input The input string to be escaped
* @param doNotEscape characters that should not be escaped * @param doNotEscape an array of characters that should not be escaped
* @return A new regex string with special characters escaped. * @return A new regex string with special characters escaped.
*/ */
// note: 'package' for testing // note: 'package' for testing
static String escapeSomeRegexCharacters(String input, char[] doNotEscape) { static String escapeSomeRegexCharacters(String input, char[] doNotEscape) {
StringBuffer buffy = new StringBuffer(); StringBuilder buffy = new StringBuilder();
for (int i = 0; i < input.length(); i++) { for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i); char c = input.charAt(i);