aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/gui
diff options
context:
space:
mode:
authorDanny van Heumen <danny@dannyvanheumen.nl>2014-12-15 23:55:44 +0100
committerDanny van Heumen <danny@dannyvanheumen.nl>2014-12-16 00:00:54 +0100
commit802f1c9e3891efcf4f33b4db7d207ef1c103a869 (patch)
tree4a896ae8a70707cd445b0324c0e30a693d79ea4f /src/net/java/sip/communicator/impl/gui
parent8501142daa999fc73b34669910fad719a53e7c99 (diff)
downloadjitsi-802f1c9e3891efcf4f33b4db7d207ef1c103a869.zip
jitsi-802f1c9e3891efcf4f33b4db7d207ef1c103a869.tar.gz
jitsi-802f1c9e3891efcf4f33b4db7d207ef1c103a869.tar.bz2
Store original message as base64-encoded content to work around issues
with copy-paste behaviour from chat conversation panel.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java2
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java26
2 files changed, 23 insertions, 5 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
index 9031c34..c625071 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
@@ -478,7 +478,7 @@ public class ChatConversationPanel
return null;
}
- String res = original_message.toString();
+ String res = new String(Base64.decode(original_message.toString()));
// Remove all newline characters that were inserted to make copying
// newlines from the conversation panel work.
// They shouldn't be in the write panel, because otherwise a newline
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
index 02fef7b..66976a2 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatHtmlUtils.java
@@ -5,6 +5,7 @@
*/
package net.java.sip.communicator.impl.gui.main.chat;
+import java.io.*;
import java.text.*;
import java.util.*;
@@ -644,8 +645,10 @@ public class ChatHtmlUtils
contactName));
messageTag.append(DATE_ATTRIBUTE).append("=\"")
.append(sdf.format(date)).append("\" ");
- messageTag.append(String.format("%s='%s' ",
- ORIGINAL_MESSAGE_ATTRIBUTE, GuiUtils.escapeHTMLChars(message)));
+ final byte[] encodedMessageBytes =
+ Base64.encode(getMessageBytes(message));
+ messageTag.append(String.format("%s=\"%s\" ",
+ ORIGINAL_MESSAGE_ATTRIBUTE, new String(encodedMessageBytes)));
messageTag.append(IncomingMessageStyle
.createSingleMessageStyle(isHistory, isEdited, true));
messageTag.append(">");
@@ -694,8 +697,10 @@ public class ChatHtmlUtils
contactName));
messageTag.append(DATE_ATTRIBUTE).append("=\"")
.append(sdf.format(date)).append("\" ");
- messageTag.append(String.format("%s='%s' ",
- ORIGINAL_MESSAGE_ATTRIBUTE, GuiUtils.escapeHTMLChars(message)));
+ final byte[] encodedMessageBytes =
+ Base64.encode(getMessageBytes(message));
+ messageTag.append(String.format("%s=\"%s\" ",
+ ORIGINAL_MESSAGE_ATTRIBUTE, new String(encodedMessageBytes)));
messageTag.append(IncomingMessageStyle
.createSingleMessageStyle(isHistory, isEdited, false));
messageTag.append(">");
@@ -717,6 +722,19 @@ public class ChatHtmlUtils
return messageTag.toString();
}
+ private static byte[] getMessageBytes(final String message) {
+ try
+ {
+ return message.getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // this should not happen since we hard-code the character encoding
+ throw new IllegalStateException("This should not happen since we "
+ + "hard-code the required character encoding.");
+ }
+ }
+
/**
* Returns the date string to show for the given date.
*