aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs/conversations/http')
-rw-r--r--src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
index c8076811..6d8024ee 100644
--- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
+++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
@@ -36,6 +36,7 @@ import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.services.AbstractConnectionManager;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
+import eu.siacs.conversations.utils.FileUtils;
public class HttpDownloadConnection implements Transferable {
@@ -83,12 +84,7 @@ public class HttpDownloadConnection implements Transferable {
mUrl = new URL(message.getBody());
}
final String sUrlFilename = mUrl.getPath().substring(mUrl.getPath().lastIndexOf('/')).toLowerCase();
- final int lastDotPosition = sUrlFilename.lastIndexOf('.');
- final int secondToLastDotPosition = sUrlFilename.lastIndexOf('.', lastDotPosition - 1);
- final String lastPart = lastDotPosition != -1 ?
- sUrlFilename.substring(lastDotPosition + 1) : "";
- final String secondToLastPart = secondToLastDotPosition != -1 ?
- sUrlFilename.substring(secondToLastDotPosition + 1, lastDotPosition - 1) : "";
+ final String lastPart = FileUtils.getLastExtension(sUrlFilename);
if (!lastPart.isEmpty() && ("pgp".equals(lastPart) || "gpg".equals(lastPart))) {
this.message.setEncryption(Message.ENCRYPTION_PGP);
@@ -98,7 +94,7 @@ public class HttpDownloadConnection implements Transferable {
}
String extension;
if (!lastPart.isEmpty() && VALID_CRYPTO_EXTENSIONS.contains(lastPart)) {
- extension = secondToLastPart;
+ extension = FileUtils.getSecondToLastExtension(sUrlFilename);
} else {
extension = lastPart;
}