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

Đang mở Phù hợp với người mới
#5,065 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, kotlin
Lĩnh vực
mobile, web-dev

Hướng nghiên cứu

Đọc owncloudApp/src/main/java/com/owncloud/android/presentation/settings/privacypolicy/PrivacyPolicyActivity.kt và helper hiện có goToUrl(url) trong ActivityExt.kt. Kiểm tra cách WebView xử lý việc điều hướng liên kết, sau đó thêm hoặc cập nhật các bài kiểm thử tập trung nếu dự án có kiểm thử cho activity này. Công việc hoàn tất khi các liên kết HTTP(S) vẫn mở trong WebView và các scheme khác được chuyển cho trình xử lý của thiết bị, đồng thời giữ nguyên hành vi hiện tại khi không có trình xử lý phù hợp.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Kotlin
Star
4.2k
Fork
3.1k
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của owncloud/android

Tất cả issue của owncloud/android

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.