1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 12:02:33 +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.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

View File

@ -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(

View File

@ -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 =