Escape search criteria

This commit is contained in:
M66B 2022-11-13 08:12:11 +01:00
parent a6d0660d29
commit 51894591ca
1 changed files with 10 additions and 1 deletions

View File

@ -873,7 +873,16 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
if (word.size() == 0)
return true;
Pattern pat = Pattern.compile(".*?\\b(" + TextUtils.join("\\s+", word) + ")\\b.*?", Pattern.DOTALL);
StringBuilder sb = new StringBuilder();
sb.append(".*?\\b(");
for (int i = 0; i < word.size(); i++) {
if (i > 0)
sb.append("\\s+");
sb.append(Pattern.quote(word.get(i)));
}
sb.append(")\\b.*?");
Pattern pat = Pattern.compile(sb.toString(), Pattern.DOTALL);
return pat.matcher(text).matches();
}