aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-04-18 15:27:08 -0700
committerGitHub <noreply@github.com>2020-04-18 15:27:08 -0700
commit6f4f98ae11fc17c29f896ce5f38e28251fff570d (patch)
tree459edd81bffb8d0e1a58f741ced6ab5f43c2ea27 /app/src/main
parentb6e1b70e860773f8040dfe5e70bbd88b6d3c7e7c (diff)
parent000699d73c55cf6bfd5e03fc3f1b24daa21dd111 (diff)
downloadfrost-6f4f98ae11fc17c29f896ce5f38e28251fff570d.tar.gz
frost-6f4f98ae11fc17c29f896ce5f38e28251fff570d.tar.bz2
frost-6f4f98ae11fc17c29f896ce5f38e28251fff570d.zip
Merge pull request #1669 from AllanWang/query-encode
Encode url query
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt5
3 files changed, 11 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 58e7d629..0cb037a5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -123,6 +123,7 @@ import com.pitchedapps.frost.utils.launchLogin
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.launchWebOverlay
import com.pitchedapps.frost.utils.setFrostColors
+import com.pitchedapps.frost.utils.urlEncode
import com.pitchedapps.frost.views.BadgedIcon
import com.pitchedapps.frost.views.FrostVideoViewer
import com.pitchedapps.frost.views.FrostViewPager
@@ -649,12 +650,13 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
if (items.isNotEmpty())
items.add(
SearchItem(
- "${FbItem._SEARCH.url}?q=$query",
+ "${FbItem._SEARCH.url}/?q=${query.urlEncode()}",
string(R.string.show_all_results),
iicon = null
)
)
searchViewCache[query] = items
+
searchView.results = items
}
}
@@ -663,7 +665,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
searchCallback =
{ query, _ ->
launchWebOverlay(
- "${FbItem._SEARCH.url}/?q=$query",
+ "${FbItem._SEARCH.url}/?q=${query.urlEncode()}",
fbCookie,
prefs
); true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
index f754b454..e1a6c814 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/parsers/MessageParser.kt
@@ -24,6 +24,7 @@ import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.facebook.get
import com.pitchedapps.frost.services.NotificationContent
import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.urlEncode
import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
@@ -39,7 +40,7 @@ import org.jsoup.nodes.Element
object MessageParser : FrostParser<FrostMessages> by MessageParserImpl() {
fun queryUser(cookie: String?, name: String) =
- parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=$name")
+ parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=${name.urlEncode()}")
}
data class FrostMessages(
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index 6db7179d..2368a992 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -71,6 +71,8 @@ import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.injectors.JsAssets
import java.io.File
import java.io.IOException
+import java.net.URLEncoder
+import java.nio.charset.StandardCharsets
import java.util.ArrayList
import java.util.Locale
import kotlinx.coroutines.CoroutineScope
@@ -370,6 +372,9 @@ val dependentSegments = arrayOf(
inline val String?.isExplicitIntent
get() = this != null && (startsWith("intent://") || startsWith("market://"))
+fun String.urlEncode(): String =
+ URLEncoder.encode(this, StandardCharsets.UTF_8.name())
+
fun Context.frostChangelog() = showChangelog(R.xml.frost_changelog)
fun Context.frostUriFromFile(file: File): Uri =