mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-31 04:56:29 -07:00
Only send source headers to the source in WebView
(cherry picked from commit a01867dc3e)
This commit is contained in:
@@ -32,6 +32,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import cafe.adriel.voyager.core.stack.mutableStateStackOf
|
||||
import com.kevinnzou.web.AccompanistWebChromeClient
|
||||
import com.kevinnzou.web.AccompanistWebViewClient
|
||||
@@ -108,6 +109,8 @@ fun WebViewScreenContent(
|
||||
onDispose { isActive = false }
|
||||
}
|
||||
|
||||
val headersHost = remember { url.toUri().host }
|
||||
|
||||
val webClient = remember {
|
||||
object : AccompanistWebViewClient() {
|
||||
override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
|
||||
@@ -147,6 +150,9 @@ fun WebViewScreenContent(
|
||||
// Ignore intents urls
|
||||
if (url.startsWith("intent://")) return true
|
||||
|
||||
// Only send source headers to the source itself
|
||||
if (request.url.host != headersHost) return false
|
||||
|
||||
// Only open valid web urls
|
||||
if (url.startsWith("http") || url.startsWith("https")) {
|
||||
if (url != view?.url) {
|
||||
|
||||
Reference in New Issue
Block a user