mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-28 04:47:56 +01:00
Spoof or remove X-Requested-With header from webview (#1812)
This commit is contained in:
@@ -219,17 +219,15 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
||||
try {
|
||||
// Override the value passed as X-Requested-With in WebView requests
|
||||
val stackTrace = Looper.getMainLooper().thread.stackTrace
|
||||
val chromiumElement = stackTrace.find {
|
||||
it.className.equals(
|
||||
"org.chromium.base.BuildInfo",
|
||||
ignoreCase = true,
|
||||
)
|
||||
}
|
||||
if (chromiumElement?.methodName.equals("getAll", ignoreCase = true)) {
|
||||
return WebViewUtil.SPOOF_PACKAGE_NAME
|
||||
val isChromiumCall = stackTrace.any {
|
||||
it.className.startsWith("org.chromium.") &&
|
||||
it.methodName in setOf("getAll", "getPackageName", "<init>")
|
||||
}
|
||||
|
||||
if (isChromiumCall) return WebViewUtil.spoofedPackageName(applicationContext)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
|
||||
return super.getPackageName()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user