-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ask the user to confirm urls which contain unicode direction overrides #6164
Conversation
… them to confirm the url
@@ -1922,30 +1925,36 @@ class TimelineFragment @Inject constructor( | |||
} | |||
}) | |||
if (!isManaged) { | |||
if (title.isValidUrl() && url.isValidUrl() && URL(title).host != URL(url).host) { | |||
MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the dialog displaying has been extracted to its own function
openUrlInExternalBrowser(requireContext(), url) | ||
when { | ||
url.containsRtLOverride() || (title.isValidUrl() && url.isValidUrl() && URL(title).host != URL(url).host) -> { | ||
displayUrlConfirmationDialog(title.ensureEndsLeftToRight(), url.filterDirectionOverrides()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url.filterDirectionOverrides()
will also be used to open the url, if the user accepts. Will it work fine? Or considerer adding url
as a new param.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah! no it should be a separate parameter, will update 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
The existing case was working finally? (you told me it was not the case)
openUrlInExternalBrowser(requireContext(), url) | ||
when { | ||
url.containsRtLOverride() || (title.isValidUrl() && url.isValidUrl() && URL(title).host != URL(url).host) -> { | ||
displayUrlConfirmationDialog(title.ensureEndsLeftToRight(), url.filterDirectionOverrides()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
url.filterDirectionOverrides()
will also be used to open the url, if the user accepts. Will it work fine? Or considerer adding url
as a new param.
// Open in external browser, in a new Tab | ||
openUrlInExternalBrowser(requireContext(), url) | ||
when { | ||
url.containsRtLOverride() || (title.isValidUrl() && url.isValidUrl() && URL(title).host != URL(url).host) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe split into 2 cases rather than using ||
for clarity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kind of~ after looking into the logic, the url detection only takes into account urls with a protocol, for example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
Matrix SDKIntegration Tests Results:
|
Type of change
Content
Checks for the presence of Right to Left unicode directional overrides when tapping on a URL, if one is found we'll show the user the URL with the overrides disabled and ask them to confirm they want to continue.
Motivation and context
Fixes #6163
Newer versions of Android (31+) seemingly handle the oddness out of the box by avoiding marking the URLs as clickable links, however previous versions will still attempt to link out to them, although the formatting is often broken.
Screenshots / GIFs
Tests
\u202E
Tested devices