You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue can be reproduced only with URLs that use both upper and lower case characters, for example: www.ex.com/SomePathWithUpperCase
If user A sends a message with such URL to user B, both users see the original URL without any issues on the UI. However, if user A or B taps on the URL inside the message content, a redirect occurs with the URL formatted entirely in lowercase: www.ex.com/somepathwithuppercase
I have identified the exact location in the io.getstream:stream-chat-android-compose:6.4.0 library where this transformation happens.
In the composable function of the library:
package io.getstream.chat.android.compose.ui.components.messages
@Composable
public fun MessageText(
message: Message,
currentUser: User?,
modifier: Modifier = Modifier,
onLongItemClick: (Message) -> Unit,
) { … }
There are two params of interest:
val styledText = ChatTheme.messageTextFormatter.format(message, currentUser)
val annotations = styledText.getStringAnnotations(0, styledText.lastIndex)
Where annotations is a list containing one Range item with:
tag = "URL"
item = "www.ex.com/somepathwithuppercase"
As you can see, the item string now has the entire text in lowercase, which breaks the original URL.
Next, when the user clicks the URL, the following block of code is executed:
ClickableText(
modifier = modifier
.padding(
start = 12.dp,
end = 12.dp,
top = 8.dp,
bottom = 8.dp,
),
text = styledText,
style = style,
onLongPress = { onLongItemClick(message) },
) { position ->
val targetUrl = annotations.firstOrNull {
position in it.start..it.end
}?.item
if (!targetUrl.isNullOrEmpty()) {
context.startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse(targetUrl),
),
)
}
}
Here, targetUrl is taken from the annotations list, which contains the formatted link in lowercase. This processing causes an error for the end user.
The text was updated successfully, but these errors were encountered:
Dependencies used in a project
Version: 6.4.0
Also can be reproduced In sample protect https://github.com/GetStream/stream-chat-android/tree/main/stream-chat-android-ui-components-sample
Description
The issue can be reproduced only with URLs that use both upper and lower case characters, for example:
www.ex.com/SomePathWithUpperCase
If user A sends a message with such URL to user B, both users see the original URL without any issues on the UI. However, if user A or B taps on the URL inside the message content, a redirect occurs with the URL formatted entirely in lowercase:
www.ex.com/somepathwithuppercase
I have identified the exact location in the io.getstream:stream-chat-android-compose:6.4.0 library where this transformation happens.
In the composable function of the library:
There are two params of interest:
For this specific case, styledText has the value:
www.ex.com/SomePathWithUpperCase
Where annotations is a list containing one Range item with:
As you can see, the item string now has the entire text in lowercase, which breaks the original URL.
Next, when the user clicks the URL, the following block of code is executed:
Here, targetUrl is taken from the annotations list, which contains the formatted link in lowercase. This processing causes an error for the end user.
The text was updated successfully, but these errors were encountered: