[BUG] PrivacyPolicyActivity WebView does not route non http(s) links out of the WebView
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 78/100
调研方向
阅读 owncloudApp/src/main/java/com/owncloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt 和 ActivityExt.kt 中现有的辅助函数 goToUrl(url)。检查其 WebView 如何处理链接导航;如果项目包含针对该 activity 的测试覆盖,则添加或更新有针对性的测试。完成标准是:HTTP(S) 链接仍在 WebView 中打开,其他 scheme 则交由设备处理程序处理,并保留现有的处理程序缺失时的行为。
由索引模型根据 Issue 内容生成。
描述
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:
- A
mailto:link in the policy text opens nothing. The WebView tries to loadmailto:[email protected]itself, fails, and the mail app never opens. - 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.
- 主要语言
- Kotlin
- 星标
- 4.2k
- 派生
- 3.1k
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
owncloud/android 的其他 Issue
-
Camera Uploads Contributions are welcome Technical
难度 2/5 1-3 小时 新手友好度 62/100
owncloud/android#5040 · 1 条评论 ·
维护者通常 1 天内回复
-
KW-related Type:bug UI / UX
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
Type:bug
难度 2/5 1-3 小时 新手友好度 74/100
owncloud/android#4485 · 6 条评论 ·
维护者通常 1 天内回复
-
Contributions are welcome p3-medium Type:bug
难度 2/5 1-3 小时 新手友好度 68/100
owncloud/android#4300 · 5 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
owncloud/android#3720 · 8 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
getsotto/sotto-authenticator#68 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 4 天内回复
-
mobile prio:low
难度 2/5 1-3 小时 新手友好度 70/100
digitalfabrik/entitlementcard#3324 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
sameerasw/essentials#1913 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 79/100
micronaut-projects/micronaut-core#14585 ·
维护者通常 1 天内回复