Fixed bug: Properly escape search string for regex

E.g. searching for [ caused a crash.
This commit is contained in:
Josia Pietsch 2024-11-26 22:33:52 +01:00
parent 3bba7cfe74
commit b8ef2a07c2
Signed by: jrpie
GPG key ID: E70B571D66986A2D

View file

@ -5,7 +5,7 @@ import de.jrpie.android.launcher.actions.AppAction
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.preferences.LauncherPreferences
import java.util.Locale
import kotlin.text.Regex.Companion.escapeReplacement
import kotlin.text.Regex.Companion.escape
class AppFilter(
var search: String,
@ -37,7 +37,7 @@ class AppFilter(
.toCharArray()
.distinct()
.filter { c -> !c.isLetter() }
.map { c -> escapeReplacement(c.toString()) }
.map { c -> escape(c.toString()) }
.fold("") { x, y -> x + y }
val disallowedCharsRegex = "[^\\p{L}$allowedSpecialCharacters]".toRegex()