add a few more know file extensions

This commit is contained in:
Daniel Gultsch 2016-03-04 11:24:53 +01:00
parent 07263370d9
commit 89eea3636f
4 changed files with 13 additions and 10 deletions

View file

@ -576,7 +576,7 @@ public class Message extends AbstractEntity {
if (dotPosition != -1) {
String extension = filename.substring(dotPosition + 1);
// we want the real file extension, not the crypto one
if (Arrays.asList(Transferable.VALID_CRYPTO_EXTENSIONS).contains(extension)) {
if (Transferable.VALID_CRYPTO_EXTENSIONS.contains(extension)) {
return extractRelevantExtension(filename.substring(0,dotPosition));
} else {
return extension;
@ -624,8 +624,8 @@ public class Message extends AbstractEntity {
} else {
return Decision.NEVER;
}
} else if (Arrays.asList(Transferable.VALID_IMAGE_EXTENSIONS).contains(extension)
|| Arrays.asList(Transferable.WELL_KNOWN_EXTENSIONS).contains(extension)) {
} else if (Transferable.VALID_IMAGE_EXTENSIONS.contains(extension)
|| Transferable.WELL_KNOWN_EXTENSIONS.contains(extension)) {
return Decision.SHOULD;
} else {
return Decision.NEVER;

View file

@ -1,10 +1,13 @@
package eu.siacs.conversations.entities;
import java.util.Arrays;
import java.util.List;
public interface Transferable {
String[] VALID_IMAGE_EXTENSIONS = {"webp", "jpeg", "jpg", "png", "jpe"};
String[] VALID_CRYPTO_EXTENSIONS = {"pgp", "gpg", "otr"};
String[] WELL_KNOWN_EXTENSIONS = {"pdf","m4a","mp4"};
List<String> VALID_IMAGE_EXTENSIONS = Arrays.asList("webp", "jpeg", "jpg", "png", "jpe");
List<String> VALID_CRYPTO_EXTENSIONS = Arrays.asList("pgp", "gpg", "otr");
List<String> WELL_KNOWN_EXTENSIONS = Arrays.asList("pdf","m4a","mp4","3gp","aac","amr","mp3");
int STATUS_UNKNOWN = 0x200;
int STATUS_CHECKING = 0x201;

View file

@ -89,7 +89,7 @@ public class HttpDownloadConnection implements Transferable {
this.message.setEncryption(Message.ENCRYPTION_NONE);
}
String extension;
if (Arrays.asList(VALID_CRYPTO_EXTENSIONS).contains(lastPart)) {
if (VALID_CRYPTO_EXTENSIONS.contains(lastPart)) {
extension = secondToLast;
} else {
extension = lastPart;

View file

@ -322,14 +322,14 @@ public class JingleConnection implements Transferable {
String[] filename = fileNameElement.getContent()
.toLowerCase(Locale.US).toLowerCase().split("\\.");
String extension = filename[filename.length - 1];
if (Arrays.asList(VALID_IMAGE_EXTENSIONS).contains(extension)) {
if (VALID_IMAGE_EXTENSIONS.contains(extension)) {
message.setType(Message.TYPE_IMAGE);
message.setRelativeFilePath(message.getUuid()+"."+extension);
} else if (Arrays.asList(VALID_CRYPTO_EXTENSIONS).contains(
} else if (VALID_CRYPTO_EXTENSIONS.contains(
filename[filename.length - 1])) {
if (filename.length == 3) {
extension = filename[filename.length - 2];
if (Arrays.asList(VALID_IMAGE_EXTENSIONS).contains(extension)) {
if (VALID_IMAGE_EXTENSIONS.contains(extension)) {
message.setType(Message.TYPE_IMAGE);
message.setRelativeFilePath(message.getUuid()+"."+extension);
} else {