always copy firefoxe’s shared files

This commit is contained in:
Daniel Gultsch 2018-02-12 12:31:59 +01:00
parent eed2d93145
commit 6650c0bd57
2 changed files with 17 additions and 2 deletions

View File

@ -44,6 +44,7 @@ import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Locale;
@ -70,6 +71,8 @@ public class FileBackend {
private XmppConnectionService mXmppConnectionService;
private static final List<String> BLACKLISTED_PATH_ELEMENTS = Arrays.asList("org.mozilla.firefox");
public FileBackend(XmppConnectionService service) {
this.mXmppConnectionService = service;
}
@ -233,9 +236,12 @@ public class FileBackend {
return result;
}
public boolean useImageAsIs(Uri uri) {
String path = getOriginalPath(uri);
if (path == null) {
if (path == null || isPathBlacklisted(path)) {
return false;
}
File file = new File(path);
@ -256,6 +262,15 @@ public class FileBackend {
}
}
public static boolean isPathBlacklisted(String path) {
for(String element : BLACKLISTED_PATH_ELEMENTS) {
if (path.contains(element)) {
return true;
}
}
return false;
}
public String getOriginalPath(Uri uri) {
return FileUtils.getPath(mXmppConnectionService, uri);
}

View File

@ -54,7 +54,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod
private void processAsFile() {
final String path = mXmppConnectionService.getFileBackend().getOriginalPath(uri);
if (path != null) {
if (path != null && !FileBackend.isPathBlacklisted(path)) {
message.setRelativeFilePath(path);
mXmppConnectionService.getFileBackend().updateFileParams(message);
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {