diff options
author | Isc <ccccym666@gmail.com> | 2020-06-06 10:21:25 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2020-06-06 11:39:07 +0300 |
commit | 566546a1dac6b2d7b6051a99fb55fc3c720d704e (patch) | |
tree | 07bdaaa3b67c400aaee5226dafe85ababcd17b34 /app/src/main | |
parent | d4f59694b507b3ef5204a8a810325c4930d9edab (diff) |
Bug fixed 846: Use Pattern.quote method to force that the searchQuery is a literal string instead of the reserved keyword in regex
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java index a6b77024..7df1f736 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/LoadNotesListTask.java @@ -9,6 +9,7 @@ import android.text.TextUtils; import android.text.format.DateUtils; import android.text.style.BackgroundColorSpan; import android.text.style.ForegroundColorSpan; +import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -64,7 +65,7 @@ public class LoadNotesListTask extends AsyncTask<Void, Void, List<Item>> { private DBNote colorTheNote(DBNote dbNote) { if (!TextUtils.isEmpty(searchQuery)) { SpannableString spannableString = new SpannableString(dbNote.getTitle()); - Matcher matcher = Pattern.compile("(" + searchQuery + ")", Pattern.CASE_INSENSITIVE).matcher(spannableString); + Matcher matcher = Pattern.compile("(" + Pattern.quote(searchQuery.toString()) + ")", Pattern.CASE_INSENSITIVE).matcher(spannableString); while (matcher.find()) { spannableString.setSpan(new ForegroundColorSpan(searchForeground), matcher.start(), matcher.end(), 0); spannableString.setSpan(new BackgroundColorSpan(searchBackground), matcher.start(), matcher.end(), 0); @@ -73,7 +74,7 @@ public class LoadNotesListTask extends AsyncTask<Void, Void, List<Item>> { dbNote.setTitle(Html.toHtml(spannableString)); spannableString = new SpannableString(dbNote.getExcerpt()); - matcher = Pattern.compile("(" + searchQuery + ")", Pattern.CASE_INSENSITIVE).matcher(spannableString); + matcher = Pattern.compile("(" + Pattern.quote(searchQuery.toString()) + ")", Pattern.CASE_INSENSITIVE).matcher(spannableString); while (matcher.find()) { spannableString.setSpan(new ForegroundColorSpan(searchForeground), matcher.start(), matcher.end(), 0); spannableString.setSpan(new BackgroundColorSpan(searchBackground), matcher.start(), matcher.end(), 0); |