fix(direct-edit): route off-server links out of the editor WebView#3192
Open
jim-daf wants to merge 1 commit into
Open
fix(direct-edit): route off-server links out of the editor WebView#3192jim-daf wants to merge 1 commit into
jim-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.