WebUIActivity WebView navigates itself for links outside the module UI
Los mantenedores suelen responder en 4 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Empieza en app/src/main/java/me/bmax/apatch/ui/WebUIActivity.kt y lee la configuración de WebViewClient, especialmente shouldInterceptRequest y doUpdateVisitedHistory. Añade el manejo de la navegación de nivel superior para que el origen de los recursos del módulo permanezca en WebView y los enlaces externos se abran mediante ACTION_VIEW; gestiona ActivityNotFoundException. El trabajo estará terminado cuando las páginas del módulo sigan cargándose internamente, los enlaces externos salgan de WebView y los enlaces no compatibles no provoquen un fallo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Is your request related to a specific issue? | 你的请求是否与某个问题相关?
While reading through WebUIActivity (app/src/main/java/me/bmax/apatch/ui/WebUIActivity.kt) I noticed that the module WebView has no say over where it navigates. The module's webroot is served through a WebViewAssetLoader on https://mui.kernelsu.org/, and the WebViewClient overrides shouldInterceptRequest and doUpdateVisitedHistory, but not shouldOverrideUrlLoading:
val webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
...
return webViewAssetLoader.shouldInterceptRequest(url)
}
override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) {
webCanGoBack = view?.canGoBack() == true
super.doUpdateVisitedHistory(view, url, isReload)
}
}
The asset loader only answers for mui.kernelsu.org. For any other host it returns null, so the WebView fetches the page from the network. When a module page contains an ordinary link to another site (project page, docs, donation link) and the user taps it, the WebView navigates itself to that site:
- The remote page is shown inside the module screen. There is no address bar, so the user cannot tell they have left the module UI.
- The
ksuobject added withaddJavascriptInterface(webViewInterface, "ksu")stays attached to the WebView, so the remote page can callksu.exec(...)andksu.spawn(...)just like the module's own page. - Non http(s) links (
mailto:,tel:,intent:) are not handed to another app. The WebView tries to load them itself and fails.
The second point is the one that matters. A module author is trusted, but a site the module happens to link to is not, and an http:// link can be modified in transit.
Describe the solution you'd like | 描述你想要的解决方案
Override shouldOverrideUrlLoading so only the asset loader origin stays in the WebView and every other top level navigation is sent out via Intent.ACTION_VIEW, wrapped in a try/catch for ActivityNotFoundException:
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
if (!request.isForMainFrame) return false
val url = request.url
if (url.scheme == "https" && url.host == "mui.kernelsu.org") return false
try {
startActivity(Intent(Intent.ACTION_VIEW, url))
} catch (_: ActivityNotFoundException) {
}
return true
}
Intent and ActivityNotFoundException are already imported in this file. Module pages keep working as before, and outside links open in the browser, where the ksu bridge does not exist.
Describe the alternatives you've considered | 描述您考虑过的备选方案
I didn't consider any other alternatives
Other information | 其他信息
The same kind of gap was fixed in Nextcloud Notes in nextcloud/notes-android#3192, where the editor WebView now keeps links to its own server and sends everything else out.
- Lenguaje dominante
- Kotlin
- Estrellas
- 8.2k
- Forks
- 809
- Merge medio
- 7 d 17 h
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bmax121/APatch
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
bmax121/APatch#1669 · 2 comentarios ·
Los mantenedores suelen responder en 4 días
-
Direct Install reports success when boot partition write failsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 4 días
-
boot_patch.sh: flash guard precedence allows flash attempt on missing new-boot.imgQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 4 días
-
HeloAbiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 5/100
Los mantenedores suelen responder en 4 días
Todos los issues de bmax121/APatch
Issues similares
-
enhancement good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsotto/sotto-authenticator#68 ·
Los mantenedores suelen responder en 1 día
-
mobile prio:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
digitalfabrik/entitlementcard#3324 ·
Los mantenedores suelen responder en 2 días
-
Contributions are welcome Type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
owncloud/android#5065 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
sameerasw/essentials#1913 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
micronaut-projects/micronaut-core#14585 ·
Los mantenedores suelen responder en 1 día