From 6650c0bd57bf6bc9cb1e7c93a8caf08cbcefda19 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 12 Feb 2018 12:31:59 +0100 Subject: [PATCH] =?UTF-8?q?always=20copy=20firefoxe=E2=80=99s=20shared=20f?= =?UTF-8?q?iles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conversations/persistance/FileBackend.java | 17 ++++++++++++++++- .../AttachFileToConversationRunnable.java | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 1ff8541b4..740b49ef1 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -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 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); } diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 5a9a0d99d..ea53844c1 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -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) {