From b18f042b8b268de70c9b1f041609b0ec708cee4c Mon Sep 17 00:00:00 2001 From: kosyak Date: Mon, 14 Oct 2024 22:14:22 +0200 Subject: [PATCH] don't create secret chat for OTR messages without resource --- .../eu/siacs/conversations/parser/MessageParser.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 76593e291..e0ae5fc04 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -597,8 +597,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain().toEscapedString()); final boolean isOTR = body != null && body.content.startsWith("?OTR") && Config.supportOtr(); + final boolean correctOTR = !isForwarded && !isTypeGroupChat && isProperlyAddressed; - if ((conversationIsProbablyMuc && !isTypeGroupChat) || (!Strings.isNullOrEmpty(counterpart.getResource()) && isOTR)) { + if ((conversationIsProbablyMuc && !isTypeGroupChat) || (!Strings.isNullOrEmpty(counterpart.getResource()) && isOTR && correctOTR)) { nextCounterpart = counterpart; } @@ -663,17 +664,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece } final Message message; if (isOTR) { - if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) { + if (correctOTR && !conversationMultiMode) { message = parseOtrChat(body.content, from, remoteMsgId, conversation); if (message == null) { return; } } else { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring OTR message from " + from + " isForwarded=" + Boolean.toString(isForwarded) + ", isProperlyAddressed=" + Boolean.valueOf(isProperlyAddressed)); - message = new Message(conversation, body.content, Message.ENCRYPTION_NONE, status); - if (body.count > 1) { - message.setBodyLanguage(body.language); - } + message = null; } } else if (pgpEncrypted != null && Config.supportOpenPgp()) { message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);