fix #2629 add quoteReplacement

This commit is contained in:
Shinsuke Sugaya 2022-02-23 21:48:24 +09:00
parent ce9d129d81
commit b4f01b5f81
2 changed files with 5 additions and 1 deletions

View file

@ -238,7 +238,7 @@ public class ViewHelper {
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.appendReplacement(buf, Matcher.quoteReplacement(highlightTagPre + matcher.group(0) + highlightTagPost));
}
matcher.appendTail(buf);
return buf.toString();

View file

@ -369,5 +369,9 @@ public class ViewHelperTest extends UnitFessTestCase {
document.put("title", "on 111 strong on aaaa");
assertEquals("<strong>on</strong> 111 str<strong>on</strong>g <strong>on</strong> <strong>aaa</strong>a",
viewHelper.getContentTitle(document));
querySet.add("$");
document.put("title", "$test");
assertEquals("<strong>$</strong>test", viewHelper.getContentTitle(document));
}
}