Skip to content

Commit bd44b61

Browse files
committed
Merge branch 'hotfix/5.44.2'
2 parents f3fa26a + 088595a commit bd44b61

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

app/src/androidTest/java/com/duckduckgo/app/systemsearch/DeviceAppLookupTest.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.duckduckgo.app.systemsearch
1818

1919
import android.content.Intent
20+
import com.duckduckgo.app.systemsearch.DeviceAppLookupTest.AppName.APP_WITH_RESERVED_CHARS
2021
import com.duckduckgo.app.systemsearch.DeviceAppLookupTest.AppName.DDG_MOVIES
2122
import com.duckduckgo.app.systemsearch.DeviceAppLookupTest.AppName.DDG_MUSIC
2223
import com.duckduckgo.app.systemsearch.DeviceAppLookupTest.AppName.FILES
@@ -100,11 +101,20 @@ class DeviceAppLookupTest {
100101
assertTrue(result.isEmpty())
101102
}
102103

104+
@Test
105+
fun whenQueryMatchesAppNameWithSpecialRegexCharactersThenAppReturnedWithoutCrashing() {
106+
whenever(mockAppProvider.get()).thenReturn(apps)
107+
val result = testee.query(APP_WITH_RESERVED_CHARS)
108+
assertEquals(1, result.size)
109+
assertEquals(APP_WITH_RESERVED_CHARS, result[0].shortName)
110+
}
111+
103112
object AppName {
104113
const val DDG_MOVIES = "DDG Movies"
105114
const val DDG_MUSIC = "DDG Music"
106115
const val LIVE_DDG = "Live DDG"
107116
const val FILES = "Files"
117+
const val APP_WITH_RESERVED_CHARS = "APP.^\$*+-?()[]{}\\|"
108118
}
109119

110120
companion object {
@@ -114,7 +124,8 @@ class DeviceAppLookupTest {
114124
DeviceApp(DDG_MOVIES, "", Intent()),
115125
DeviceApp(DDG_MUSIC, "", Intent()),
116126
DeviceApp(FILES, "", Intent()),
117-
DeviceApp(LIVE_DDG, "", Intent())
127+
DeviceApp(LIVE_DDG, "", Intent()),
128+
DeviceApp(APP_WITH_RESERVED_CHARS, "", Intent())
118129
)
119130
}
120131
}

app/src/main/java/com/duckduckgo/app/systemsearch/DeviceAppLookup.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class InstalledDeviceAppLookup(private val appListProvider: DeviceAppListProvide
5656
refreshAppList()
5757
}
5858

59-
val wordPrefixMatchingRegex = ".*\\b${query}.*".toRegex(IGNORE_CASE)
59+
val escapedQuery = Regex.escape(query)
60+
val wordPrefixMatchingRegex = ".*\\b${escapedQuery}.*".toRegex(IGNORE_CASE)
6061
return apps!!.filter {
6162
it.shortName.matches(wordPrefixMatchingRegex)
6263
}

app/version/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=5.44.1
1+
VERSION=5.44.2

0 commit comments

Comments
 (0)