[BUG] PrivacyPolicyActivity WebView does not route non http(s) links out of the WebView

Abierto Apto para principiantes
#5,065 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin
Área
mobile, web-dev

Línea de trabajo

Lee owncloudApp/src/main/java/com/owncloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt y el helper existente goToUrl(url) en ActivityExt.kt. Comprueba cómo gestiona su WebView la navegación por enlaces y añade o actualiza pruebas específicas si el proyecto tiene cobertura para esta actividad. La tarea estará terminada cuando los enlaces HTTP(S) permanezcan en el WebView y los demás esquemas se deleguen al controlador del dispositivo, conservando el comportamiento existente cuando no haya ningún controlador disponible.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Contributions are welcome Type:bug

PrivacyPolicyActivity (owncloudApp/src/main/java/com/owncloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt) sets up its WebViewClient with only an onReceivedError override:

webViewClient = object : WebViewClient() {
    override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
        showMessageInSnackbar(message = getString(R.string.privacy_policy_error) + description)
    }
}

Because shouldOverrideUrlLoading is not overridden, every link the privacy policy page renders is loaded by the WebView itself. That has two visible effects:

  1. A mailto: link in the policy text opens nothing. The WebView tries to load mailto:[email protected] itself, fails, and the mail app never opens.
  2. Any other non http(s) scheme that an app on the device could handle (tel:, geo:, intent:, market:) is swallowed by the WebView the same way instead of being handed to that app.

The page is remote (url_privacy_policy, https://owncloud.com/android-app-privacy-policy/ by default, and a branded build can point it somewhere else), so which links it contains is outside the app's control.

Suggested fix

Override shouldOverrideUrlLoading so http(s) navigations stay in the WebView and any other scheme is routed out. ActivityExt.kt already has goToUrl(url), which launches Intent.ACTION_VIEW inside a try/catch for ActivityNotFoundException and shows the file_list_no_app_for_perform_action snackbar, so a missing handler does not crash the Activity:

override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
    val url = request?.url ?: return false
    val scheme = url.scheme?.lowercase()
    if (scheme == "http" || scheme == "https") return false
    goToUrl(url.toString())
    return true
}

The same gap was fixed in the OpenCloud fork of this app in opencloud-eu/android#165.

Lenguaje dominante
Kotlin
Estrellas
4.2k
Forks
3.1k
Merge medio
2 d 1 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de owncloud/android

Todos los issues de owncloud/android

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.