From 2236cd036796124dbf80cbd358d74e668b16d711 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Tue, 11 Feb 2020 16:15:05 +0100 Subject: [PATCH] Enhancement: Ensure added HTML is converted back to its original format when identifying signature. --- app/assets/javascripts/app/lib/app_post/utils.coffee | 3 ++- public/assets/tests/html_utils.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 956889672..fd9b23bef 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -681,7 +681,8 @@ class App.Utils $('
').html(message).contents().each (index, node) -> text = $(node).text() if node.nodeType == Node.TEXT_NODE - res.push text + # convert text back to HTML as it was before + res.push $('
').text(text).html() if text.trim().length contentNodes.push index else if node.nodeType == Node.ELEMENT_NODE diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index 37234a117..d208dd8cc 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -3367,3 +3367,8 @@ test('App.Utils.clipboardHtmlInsertPreperation()', function() { equal(App.Utils.clipboardHtmlInsertPreperation('
test
123
', { mode: 'textonly', multiline: true }), 'test
123') }); +test('App.Utils.signatureIdentifyByHtmlHelper()', function() { + result = App.Utils.signatureIdentifyByHtmlHelper("<script>alert('fish2');</script>
") + + equal(result, "<script>alert('fish2');</script>
", 'signatureIdentifyByHtmlHelper does not reactivate alert') +});