Add MediaSource.withCleanUrl method that removes invalid fragment data from MXC urls

We've seen some MXC urls in the wild having some `mxc://foo/bar#auto` fragment suffix, which is invalid, but the URL before that fragment part is valid and can be displayed
This commit is contained in:
Jorge Martín 2026-01-19 09:55:45 +01:00
parent f2e783064e
commit fecbabb0e4
3 changed files with 36 additions and 7 deletions

View file

@ -14,6 +14,7 @@ import io.element.android.libraries.core.mimetype.MimeTypes
import io.element.android.libraries.matrix.api.media.MatrixMediaLoader
import io.element.android.libraries.matrix.api.media.MediaFile
import io.element.android.libraries.matrix.api.media.MediaSource
import io.element.android.libraries.matrix.api.media.withCleanUrl
import kotlinx.coroutines.withContext
import org.matrix.rustcomponents.sdk.Client
import org.matrix.rustcomponents.sdk.use
@ -91,7 +92,7 @@ class RustMediaLoader(
return if (json != null) {
RustMediaSource.fromJson(json)
} else {
RustMediaSource.fromUrl(url)
RustMediaSource.fromUrl(withCleanUrl().url)
}
}
}