fix #2356 check if pattern exists
This commit is contained in:
parent
ba0ff8b075
commit
ee61a2b778
1 changed files with 13 additions and 12 deletions
|
@ -216,18 +216,19 @@ public class ViewHelper {
|
|||
if (!fessConfig.isResponseHighlightContentTitleEnabled()) {
|
||||
return value;
|
||||
}
|
||||
return getQuerySet().map(
|
||||
querySet -> {
|
||||
final Matcher matcher =
|
||||
Pattern.compile(querySet.stream().map(LaFunctions::h).map(Pattern::quote).collect(Collectors.joining("|")),
|
||||
Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE).matcher(value);
|
||||
final StringBuffer buf = new StringBuffer(value.length() + 100);
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buf, highlightTagPre + matcher.group(0) + highlightTagPost);
|
||||
}
|
||||
matcher.appendTail(buf);
|
||||
return buf.toString();
|
||||
}).orElse(value);
|
||||
return getQuerySet().map(querySet -> {
|
||||
final String pattern = querySet.stream().map(LaFunctions::h).map(Pattern::quote).collect(Collectors.joining("|"));
|
||||
if (StringUtil.isBlank(pattern)) {
|
||||
return null;
|
||||
}
|
||||
final Matcher matcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE).matcher(value);
|
||||
final StringBuffer buf = new StringBuffer(value.length() + 100);
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(buf, highlightTagPre + matcher.group(0) + highlightTagPost);
|
||||
}
|
||||
matcher.appendTail(buf);
|
||||
return buf.toString();
|
||||
}).orElse(value);
|
||||
}
|
||||
|
||||
protected OptionalThing<Set<String>> getQuerySet() {
|
||||
|
|
Loading…
Add table
Reference in a new issue