mattermost / mattermost-mobile

Next generation iOS and Android apps for Mattermost in React Native
https://about.mattermost.com/
Apache License 2.0
2.2k stars 1.33k forks source link

Crash when there is a message with attachment whose footer icon URL is unreachable #4665

Closed jfcastroluis closed 1 year ago

jfcastroluis commented 4 years ago

Summary

Mobile application crashes turning to a black screen when there is a message with attachment whose footer icon URL is unreachable.

Environment Information

Steps to reproduce

Create a post with an attachment whose footer icon URL is unreachable.

For example:

WEBHOOK="https://chat.example.com/hooks/XXXXXXXXXXXXXXXXXXX"

attachment=$(cat <<EOF
{
  "color": "#000000",
  "title": "title",
  "footer": "footer",
  "footer_icon": "https://example.com/unreachable.jpg"
}
EOF
)

message=$(cat <<EOF
{
  "attachments": [$attachment]
}
EOF
)

curl -i -X POST --data-urlencode "payload=$message" $WEBHOOK

Expected behavior

It is expected to show the typical broken image icon where icon should be (or perhaps show nothing)

Observed behavior

The mobile application crashes turning to a black screen while on desktop browser the typical broken image icon is showed.

enahum commented 4 years ago

@jfcastroluis Thanks for the report, I did tried to replicate but it seems to be working fine for me (no image rendered)

iOS Android
image image
enahum commented 4 years ago

@jfcastroluis Were you able to confirm that is in fact the wring image in the footer causing the issue? I’ve used your same example and seen no crash as my comment above shows

jfcastroluis commented 4 years ago

Hi @enahum

Sorry about my delay answering to this issue :(

I checked again and I was wrong. The problem is when footer_icon is a relative URL. Something like /api/v4/users/3c8qt6dce3ynz8yjm9z7eojo4w/image

I understand that could not work properly because of the non-sense relative URL (actually now I concat the main domain before) but that causes a crash of the application turning to a black screen.

So, create a post with an attachment whose footer icon URL is relative:

WEBHOOK="https://chat.example.com/hooks/XXXXXXXXXXXXXXXXXXX"

attachment=$(cat <<EOF
{
  "color": "#000000",
  "title": "title",
  "footer": "footer",
  "footer_icon": "/api/v4/users/3c8qt6dce3ynz8yjm9z7eojo4w/image"
}
EOF
)

message=$(cat <<EOF
{
  "attachments": [$attachment]
}
EOF
)

curl -i -X POST --data-urlencode "payload=$message" $WEBHOOK
larkox commented 1 year ago

This should be solved on V2.