mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git log] Fix multi-value filter by user
Escaping baskslashes in 7eea76a introduced the problem with "\|"
separator used by Git to allow several users.
Backslashes should be escaped separately for text filter
and user filter: in the latter they should be escaped as well
(to allow a non-likely but possible case with backslash in user name)
before escaping "|".
This commit is contained in:
@@ -1720,7 +1720,7 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String escapeChar(@NotNull final String str, final char character) {
|
||||
public static String escapeChar(@NotNull final String str, final char character) {
|
||||
final StringBuilder buf = new StringBuilder(str);
|
||||
escapeChar(buf, character);
|
||||
return buf.toString();
|
||||
|
||||
@@ -222,7 +222,7 @@ public class GitLogProvider implements VcsLogProvider {
|
||||
return filter.getUserName(root);
|
||||
}
|
||||
});
|
||||
filterParameters.add(prepareParameter("author", authorFilter));
|
||||
filterParameters.add(prepareParameter("author", StringUtil.escapeChar(StringUtil.escapeBackSlashes(authorFilter), '|')));
|
||||
}
|
||||
|
||||
if (!dateFilters.isEmpty()) {
|
||||
@@ -240,7 +240,7 @@ public class GitLogProvider implements VcsLogProvider {
|
||||
LOG.warn("Expected only one text filter: " + textFilters);
|
||||
}
|
||||
else if (!textFilters.isEmpty()) {
|
||||
String textFilter = textFilters.iterator().next().getText();
|
||||
String textFilter = StringUtil.escapeBackSlashes(textFilters.iterator().next().getText());
|
||||
filterParameters.add(prepareParameter("grep", textFilter));
|
||||
}
|
||||
|
||||
@@ -278,12 +278,11 @@ public class GitLogProvider implements VcsLogProvider {
|
||||
}
|
||||
|
||||
private static String prepareParameter(String paramName, String value) {
|
||||
// no value quoting needed, because the parameter itself will be quoted by GeneralCommandLine
|
||||
return "--" + paramName + "=" + StringUtil.escapeBackSlashes(value);
|
||||
return "--" + paramName + "=" + value; // no value quoting needed, because the parameter itself will be quoted by GeneralCommandLine
|
||||
}
|
||||
|
||||
private static <T> String joinFilters(Collection<T> filters, Function<T, String> toString) {
|
||||
return StringUtil.join(filters, toString, "\\|");
|
||||
return StringUtil.join(filters, toString, "|");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user