1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Merge pull request #1669 from AllanWang/query-encode

Encode url query
This commit is contained in:
Allan Wang 2020-04-18 15:27:08 -07:00 committed by GitHub
commit 6f4f98ae11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -123,6 +123,7 @@ import com.pitchedapps.frost.utils.launchLogin
import com.pitchedapps.frost.utils.launchNewTask import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.launchWebOverlay import com.pitchedapps.frost.utils.launchWebOverlay
import com.pitchedapps.frost.utils.setFrostColors import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.utils.urlEncode
import com.pitchedapps.frost.views.BadgedIcon import com.pitchedapps.frost.views.BadgedIcon
import com.pitchedapps.frost.views.FrostVideoViewer import com.pitchedapps.frost.views.FrostVideoViewer
import com.pitchedapps.frost.views.FrostViewPager import com.pitchedapps.frost.views.FrostViewPager
@ -649,12 +650,13 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
if (items.isNotEmpty()) if (items.isNotEmpty())
items.add( items.add(
SearchItem( SearchItem(
"${FbItem._SEARCH.url}?q=$query", "${FbItem._SEARCH.url}/?q=${query.urlEncode()}",
string(R.string.show_all_results), string(R.string.show_all_results),
iicon = null iicon = null
) )
) )
searchViewCache[query] = items searchViewCache[query] = items
searchView.results = items searchView.results = items
} }
} }
@ -663,7 +665,7 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
searchCallback = searchCallback =
{ query, _ -> { query, _ ->
launchWebOverlay( launchWebOverlay(
"${FbItem._SEARCH.url}/?q=$query", "${FbItem._SEARCH.url}/?q=${query.urlEncode()}",
fbCookie, fbCookie,
prefs prefs
); true ); true

View File

@ -24,6 +24,7 @@ import com.pitchedapps.frost.facebook.formattedFbUrl
import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.facebook.get
import com.pitchedapps.frost.services.NotificationContent import com.pitchedapps.frost.services.NotificationContent
import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.urlEncode
import org.apache.commons.text.StringEscapeUtils import org.apache.commons.text.StringEscapeUtils
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
@ -39,7 +40,7 @@ import org.jsoup.nodes.Element
object MessageParser : FrostParser<FrostMessages> by MessageParserImpl() { object MessageParser : FrostParser<FrostMessages> by MessageParserImpl() {
fun queryUser(cookie: String?, name: String) = fun queryUser(cookie: String?, name: String) =
parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=$name") parseFromUrl(cookie, "${FbItem.MESSAGES.url}/?q=${name.urlEncode()}")
} }
data class FrostMessages( data class FrostMessages(

View File

@ -71,6 +71,8 @@ import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.injectors.JsAssets import com.pitchedapps.frost.injectors.JsAssets
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import java.util.ArrayList import java.util.ArrayList
import java.util.Locale import java.util.Locale
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -370,6 +372,9 @@ val dependentSegments = arrayOf(
inline val String?.isExplicitIntent inline val String?.isExplicitIntent
get() = this != null && (startsWith("intent://") || startsWith("market://")) 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.frostChangelog() = showChangelog(R.xml.frost_changelog)
fun Context.frostUriFromFile(file: File): Uri = fun Context.frostUriFromFile(file: File): Uri =