From 8d0fd823a4cec727bb2dd9075de26bf430c27824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Tantau?= Date: Tue, 24 Jan 2023 16:52:57 +0100 Subject: Only check for file extensions (#1299) Links that end with jpeg without a dot before it are usually not images. Like here https://www.reddit.com/r/ProgrammerHumor/comments/zxro3m/weinersmith_has_escalated_the_gif_geif_vs_jiff/ --- .../infinityforreddit/activities/LinkResolverActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/ml/docilealligator') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index f8ce9884..96d55b09 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -114,7 +114,7 @@ public class LinkResolverActivity extends AppCompatActivity { path = path.substring(0, path.length() - 1); } - if (path.endsWith("jpg") || path.endsWith("png") || path.endsWith("jpeg")) { + if (path.endsWith(".jpg") || path.endsWith(".png") || path.endsWith(".jpeg")) { Intent intent = new Intent(this, ViewImageOrGifActivity.class); String url = uri.toString(); String fileName = FilenameUtils.getName(path); @@ -122,7 +122,7 @@ public class LinkResolverActivity extends AppCompatActivity { intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, fileName); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, fileName); startActivity(intent); - } else if (path.endsWith("gif")) { + } else if (path.endsWith(".gif")) { Intent intent = new Intent(this, ViewImageOrGifActivity.class); String url = uri.toString(); String fileName = FilenameUtils.getName(path); @@ -130,7 +130,7 @@ public class LinkResolverActivity extends AppCompatActivity { intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, fileName); intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, fileName); startActivity(intent); - } else if (path.endsWith("mp4")) { + } else if (path.endsWith(".mp4")) { Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); -- cgit v1.2.3