From ec8b7b5be1e50adcd4c2d8333f142abd2f3ba01a Mon Sep 17 00:00:00 2001 From: Denny Bresch Date: Fri, 26 Jul 2019 16:44:30 +0200 Subject: [PATCH] Fixes #2325 - remove blockquote blocks before checking if attachment is referenced in message. --- app/assets/javascripts/app/lib/app_post/utils.coffee | 8 ++++++-- public/assets/tests/html_utils.js | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 6ea202fa0..810bee3eb 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -821,12 +821,16 @@ class App.Utils # en attachmentTranslatedRegExp = new RegExp("\\W#{word}\\W", 'i') - return word if message.match(attachmentTranslatedRegExp) + + # remove blockquote, check only the unquoted content + return word if message.replace(/(
.*<\/blockquote>)/g, "").match(attachmentTranslatedRegExp) # user locale attachmentTranslated = App.i18n.translateContent(word) attachmentTranslatedRegExp = new RegExp("\\W#{attachmentTranslated}\\W", 'i') - return attachmentTranslated if message.match(attachmentTranslatedRegExp) + + # remove blockquote, check only the unquoted content + return attachmentTranslated if message.replace(/(
.*<\/blockquote>)/g, "").match(attachmentTranslatedRegExp) false # human readable file size diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index 0294bd8f1..acb98b33c 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -1281,6 +1281,11 @@ test("check check attachment reference", function() { result = 'Enclosed' verify = App.Utils.checkAttachmentReference(message) equal(verify, result) + + message = '
Hi Test,
On Monday, 22 July 2019, 14:07:54, Test User wrote:

Test attachment
' + result = false + verify = App.Utils.checkAttachmentReference(message) + equal(verify, result) }); // replace tags