Change summary
src/main/java/eu/siacs/conversations/entities/Message.java | 2
src/main/java/eu/siacs/conversations/services/MessageSearchTask.java | 2
src/main/java/eu/siacs/conversations/utils/MessageUtils.java | 4
3 files changed, 4 insertions(+), 4 deletions(-)
Detailed changes
@@ -1378,7 +1378,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
public synchronized boolean treatAsDownloadable() {
if (treatAsDownloadable == null) {
- treatAsDownloadable = MessageUtils.treatAsDownloadable(this.body, isOOb());
+ treatAsDownloadable = MessageUtils.treatAsDownloadable(this.body, isOOb(), encryption != ENCRYPTION_NONE);
}
return treatAsDownloadable;
}
@@ -109,7 +109,7 @@ public class MessageSearchTask implements Runnable, Cancellable {
}
final String body = cursor.getString(indexBody);
final boolean oob = cursor.getInt(indexOob) > 0;
- if (MessageUtils.treatAsDownloadable(body,oob)) {
+ if (MessageUtils.treatAsDownloadable(body,oob,false)) {
continue;
}
final String conversationUuid = cursor.getString(indexConversation);
@@ -77,7 +77,7 @@ public class MessageUtils {
return builder.toString();
}
- public static boolean treatAsDownloadable(final String body, final boolean oob) {
+ public static boolean treatAsDownloadable(final String body, final boolean oob, final boolean legacyEncryption) {
if (oob) return true;
final String[] lines = body.split("\n");
@@ -104,7 +104,7 @@ public class MessageUtils {
final boolean followedByDataUri = lines.length == 2 && lines[1].startsWith("data:");
final boolean validAesGcm = AesGcmURL.PROTOCOL_NAME.equalsIgnoreCase(protocol) && encrypted && (lines.length == 1 || followedByDataUri);
final boolean validProtocol = "http".equalsIgnoreCase(protocol) || "https".equalsIgnoreCase(protocol);
- final boolean validOob = validProtocol && (oob || encrypted) && lines.length == 1;
+ final boolean validOob = validProtocol && (oob || encrypted || (legacyEncryption && uri.getPath() != null && (uri.getPath().endsWith(".xdc") || uri.getPath().endsWith(".webp") || uri.getPath().endsWith(".gif") || uri.getPath().endsWith(".png")))) && lines.length == 1;
return validAesGcm || validOob;
}