diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-21 14:58:12 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-21 14:58:12 +0000 |
commit | 7803b376b2b6415380cb0317b15456d043d72078 (patch) | |
tree | b27c2978debf06444697af3a27189295f7353094 /app/src/main/java/ml/docilealligator | |
parent | 63e27eb23a87835768f725f4ab7e0dffd56575c2 (diff) | |
download | infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar.gz infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar.bz2 infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar.lz infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar.xz infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.tar.zst infinity-for-reddit-7803b376b2b6415380cb0317b15456d043d72078.zip |
Fix app crashes when downloading images from a specific domain.
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java | 8 |
1 files changed, 8 insertions, 0 deletions
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 e4b9387c..e0154df2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -119,8 +119,16 @@ public class LinkResolverActivity extends AppCompatActivity { if (authority != null) { if (authority.equals("reddit-uploaded-media.s3-accelerate.amazonaws.com")) { + String unescapedUrl = uri.toString().replace("%2F", "/"); + int lastSlashIndex = unescapedUrl.lastIndexOf("/"); + if (lastSlashIndex < 0 || lastSlashIndex == unescapedUrl.length() - 1) { + deepLinkError(uri); + return; + } + String id = unescapedUrl.substring(lastSlashIndex + 1); Intent intent = new Intent(this, ViewImageOrGifActivity.class); intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, uri.toString()); + intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, id + ".jpg"); startActivity(intent); } else if (authority.equals("v.redd.it")) { Intent intent = new Intent(this, ViewVideoActivity.class); |