fix(direct-edit): route off-server links out of the editor WebView#3192
fix(direct-edit): route off-server links out of the editor WebView#3192jim-daf wants to merge 1 commit into
Conversation
The direct-edit WebView loads the Nextcloud Text editor for the user's account but never overrides shouldOverrideUrlLoading, so any link the editor renders (mentions to other users, file references, embedded images, mailto: in a markdown table) navigates the editor WebView itself and breaks the edit session. Override shouldOverrideUrlLoading to keep navigations whose URL starts with the current account URL inside the WebView and route everything else out via Intent.ACTION_VIEW. Wrap the launch in try/catch so a missing handler does not crash the Fragment.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 minor |
🟢 Metrics 0 duplication
Metric Results Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Closes #3191.
The
NoteDirectEditFragmentWebView loads the Nextcloud Text editor for the user's account but does not overrideshouldOverrideUrlLoading. Any link the editor renders (a markdown link to another site, amailto:in a frontmatter table, a mention to a user on a different Nextcloud server) navigates the editor WebView itself, which drops the user out of the edit session.Change
Override
shouldOverrideUrlLoading. Keep navigations whose URL starts with the current account URL inside the WebView (so server-internal links the editor produces continue to work). Route everything else out viaIntent.ACTION_VIEW. Wrap the launch intry/catch (ActivityNotFoundException)so a missing handler does not crash the Fragment:The
runCatchingaroundaccount.urlis so a transient access failure here cannot crash the WebViewClient callback. If the account URL is not available we just fall through to the external-route branch instead of blowing up.Behaviour
httpslink inside the editor (the case the editor actually produces): unchanged, stays in the WebView.httpslink tapped from a note: opens in the system browser.mailto:,tel:,intent:link tapped from a note: opens in the matching system app.