aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/otr
diff options
context:
space:
mode:
authorMarin <m.dzhigarov@gmail.com>2014-01-06 09:39:27 +0200
committerMarin <m.dzhigarov@gmail.com>2014-01-06 10:29:06 +0200
commitd51c519a6d099d073c7d8d4be308acf5e6be7211 (patch)
tree4f9ca94873b9d296c3c267d7dbb3dfbadd2f463c /src/net/java/sip/communicator/plugin/otr
parent9dc6b6ef1d4d5d2b9c0c73cd4335844649b462ca (diff)
downloadjitsi-d51c519a6d099d073c7d8d4be308acf5e6be7211.zip
jitsi-d51c519a6d099d073c7d8d4be308acf5e6be7211.tar.gz
jitsi-d51c519a6d099d073c7d8d4be308acf5e6be7211.tar.bz2
Fixes HTML being shown in OTR messages
Diffstat (limited to 'src/net/java/sip/communicator/plugin/otr')
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrTransformLayer.java10
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java21
2 files changed, 28 insertions, 3 deletions
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrTransformLayer.java b/src/net/java/sip/communicator/plugin/otr/OtrTransformLayer.java
index 44e0f0e..5ba5a53 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrTransformLayer.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrTransformLayer.java
@@ -94,7 +94,11 @@ public class OtrTransformLayer
contact.getProtocolProvider().getOperationSet(
OperationSetBasicInstantMessaging.class);
Message processedMessage =
- imOpSet.createMessage(processedMessageContent);
+ imOpSet.createMessage(
+ processedMessageContent,
+ evt.getSourceMessage().getContentType(),
+ evt.getSourceMessage().getEncoding(),
+ evt.getSourceMessage().getSubject());
// Create a new event and return.
MessageDeliveredEvent processedEvent =
@@ -140,7 +144,9 @@ public class OtrTransformLayer
OperationSetBasicInstantMessaging.class);
Message processedMessage =
imOpSet.createMessageWithUID(
- processedMessageContent, evt.getSourceMessage().getMessageUID());
+ processedMessageContent,
+ evt.getSourceMessage().getContentType(),
+ evt.getSourceMessage().getMessageUID());
// Create a new event and return.
MessageReceivedEvent processedEvent =
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
index 5e00234..b7fb849 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
@@ -62,7 +62,26 @@ public class ScOtrEngineImpl
.getProtocolProvider()
.getOperationSet(
OperationSetBasicInstantMessaging.class);
- Message message = imOpSet.createMessage(messageText);
+
+ // This is a dirty way of detecting whether the injected message
+ // contains HTML markup. If this is the case then we should create
+ // the message with the appropriate content type so that the remote
+ // party can properly display the HTML.
+ // When otr4j injects QueryMessages it calls
+ // OtrEngineHost.getFallbackMessage() which is currently the only
+ // host method that uses HTML so we can simply check if the injected
+ // message contains the string that getFallbackMessage() returns.
+ String otrHtmlFallbackMessage =
+ "<a href=\"http://en.wikipedia.org/wiki/Off-the-Record_Messaging\">";
+ String contentType =
+ messageText.contains(otrHtmlFallbackMessage)
+ ? imOpSet.HTML_MIME_TYPE : imOpSet.DEFAULT_MIME_TYPE;
+
+ Message message =
+ imOpSet.createMessage( messageText,
+ contentType,
+ imOpSet.DEFAULT_MIME_ENCODING,
+ null);
injectedMessageUIDs.add(message.getMessageUID());
imOpSet.sendInstantMessage(contact, message);