diff --git a/src/gui/Pages/Chat/Timeline/EventList.qml b/src/gui/Pages/Chat/Timeline/EventList.qml index 87d7053b..0218e437 100644 --- a/src/gui/Pages/Chat/Timeline/EventList.qml +++ b/src/gui/Pages/Chat/Timeline/EventList.qml @@ -126,9 +126,14 @@ Rectangle { } if (! eventList.selectedCount && eventList.currentIndex !== -1) { - Clipboard.text = JSON.parse( - eventList.model.get(eventList.currentIndex).source - ).body + const model = eventList.model.get(eventList.currentIndex) + const source = JSON.parse(model.source) + + Clipboard.text = + "body" in source ? + source.body : + utils.stripHtmlTags(utils.processedEventText(model)) + return } diff --git a/src/gui/Utils.qml b/src/gui/Utils.qml index 3d7f5b8b..2c1edcaf 100644 --- a/src/gui/Utils.qml +++ b/src/gui/Utils.qml @@ -163,13 +163,19 @@ QtObject { } - function escapeHtml(string) { + function escapeHtml(text) { // Replace special HTML characters by encoded alternatives - return string.replace("&", "&") - .replace("<", "<") - .replace(">", ">") - .replace('"', """) - .replace("'", "'") + return text.replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace('"', """) + .replace("'", "'") + } + + + function stripHtmlTags(text) { + // XXX: Potentially unsafe! + return text.replace(/<\/?[^>]+(>|$)/g, "") }