diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-05-03 21:52:29 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-05-03 21:52:29 +0200 |
commit | a6a1f89124c09d325a4570025df974b35158ebda (patch) | |
tree | d14e938e5b10c9e64ecb7ee54b76f9a98735917c /src/main/java | |
parent | e52b3d8942ec9843533c0a08040e8b8436aa4454 (diff) |
handle invalid image bounds
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 8 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index c4107e863..7ba41d8ad 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -912,7 +912,9 @@ public class FileBackend { if (image || video) { try { Dimensions dimensions = image ? getImageDimensions(file) : getVideoDimensions(file); - body.append('|').append(dimensions.width).append('|').append(dimensions.height); + if (dimensions.valid()) { + body.append('|').append(dimensions.width).append('|').append(dimensions.height); + } } catch (NotAVideoFile notAVideoFile) { Log.d(Config.LOGTAG, "file with mime type " + file.getMimeType() + " was not a video file"); //fall threw @@ -1096,6 +1098,10 @@ public class FileBackend { public int getMin() { return Math.min(width, height); } + + public boolean valid() { + return width > 0 && height > 0; + } } private static class NotAVideoFile extends Exception { diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 148d96bb3..a14e1057b 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -924,9 +924,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } else { displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first, darkBackground); } - } else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { - displayImageMessage(viewHolder, message); - } else if (message.getType() == Message.TYPE_FILE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { + } else if (message.isFileOrImage() && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { if (message.getFileParams().width > 0 && message.getFileParams().height > 0) { displayImageMessage(viewHolder, message); } else if (message.getFileParams().runtime > 0) { |