Improve spoofing of X-Requested-With header to support newer WebView versions (mihonapp/mihon#2491)

Co-authored-by: Cuong-Tran <cuongtran.tm@gmail.com>
(cherry picked from commit 065147472e8e683c47d11f3e00386aba2a7c1bac)
This commit is contained in:
Guzmazow 2025-09-19 20:35:23 +03:00 committed by Cuong-Tran
parent e6bddcab14
commit 136fb7652c
2 changed files with 9 additions and 2 deletions

View file

@ -14,6 +14,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
### Changed
- Delegate Suwayomi tracker authentication to extension ([@cpiber](https://github.com/cpiber)) ([#2476](https://github.com/mihonapp/mihon/pull/2476))
### Improved
- Spoofing of `X-Requested-With` header to support newer WebView versions ([@Guzmazow](https://github.com/Guzmazow)) ([#2491](https://github.com/mihonapp/mihon/pull/2491))
### Fixes
- Fix height of description not being calculated correctly if images are present ([@Secozzi](https://github.com/Secozzi)) ([#2382](https://github.com/mihonapp/mihon/pull/2382))
- Fix migration progress not updating after manual search ([@Secozzi](https://github.com/Secozzi)) ([#2484](https://github.com/mihonapp/mihon/pull/2484))

View file

@ -303,9 +303,13 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
try {
// Override the value passed as X-Requested-With in WebView requests
val stackTrace = Looper.getMainLooper().thread.stackTrace
// KMK -->
val chromiumClasses = setOf("org.chromium.base.buildinfo", "org.chromium.base.apkinfo")
val chromiumMethods = setOf("getall", "getpackagename", "<init>")
// KMK <--
val isChromiumCall = stackTrace.any { trace ->
trace.className.equals("org.chromium.base.BuildInfo", ignoreCase = true) &&
setOf("getAll", "getPackageName", "<init>").any { trace.methodName.equals(it, ignoreCase = true) }
trace.className.lowercase() in chromiumClasses &&
trace.methodName.lowercase() in chromiumMethods
}
if (isChromiumCall) return WebViewUtil.spoofedPackageName(applicationContext)