mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
temporarily disable image with extension like '.ico' to make it the same iOS (just accept jpg, png and gif)
This commit is contained in:
parent
2a3c2fdb28
commit
14a5ff0546
@ -147,6 +147,11 @@ public class LinkPreviewRepository implements InjectableType {
|
||||
imageUrl = Optional.absent();
|
||||
}
|
||||
|
||||
if (imageUrl.isPresent() && !LinkPreviewUtil.isVaildMimeType(imageUrl.get())) {
|
||||
Log.i(TAG, "Image URL was invalid mime type. Skipping.");
|
||||
imageUrl = Optional.absent();
|
||||
}
|
||||
|
||||
callback.onComplete(new Metadata(title, imageUrl));
|
||||
}
|
||||
});
|
||||
|
@ -17,6 +17,7 @@ import org.thoughtcrime.securesms.util.DateUtils;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -96,6 +97,15 @@ public final class LinkPreviewUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVaildMimeType(@NonNull String url) {
|
||||
String[] vaildMimeType = {"jpg", "png", "gif", "jpeg"};
|
||||
if (url.contains(".")) {
|
||||
String extenstion = url.substring(url.lastIndexOf(".") + 1).toLowerCase();
|
||||
return Arrays.asList(vaildMimeType).contains(extenstion);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static @NonNull OpenGraph parseOpenGraphFields(@Nullable String html) {
|
||||
return parseOpenGraphFields(html, text -> Html.fromHtml(text).toString());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user