From 59f9f1a1b6c139fa7c71ee848ccaa681c41665b3 Mon Sep 17 00:00:00 2001 From: Denny Bresch Date: Tue, 30 Jul 2019 15:52:14 +0200 Subject: [PATCH] Follow up - ec8b7b5be1e50adcd4c2d8333f142abd2f3ba01a - Fixes #2325 - remove blockquote blocks before checking if attachment is referenced in message. --- .../javascripts/app/lib/app_post/utils.coffee | 15 ++++++++------- public/assets/tests/html_utils.js | 12 +++++++++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee index 810bee3eb..f29dbdfa6 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.coffee @@ -816,21 +816,22 @@ class App.Utils # check if attachment is referenced in message @checkAttachmentReference: (message) -> return false if !message + + # remove blockquote from message, check only the unquoted content + tmp = $('
' + message + '
') + tmp.find('blockquote').remove() + text = tmp.text() + matchwords = ['Attachment', 'attachment', 'Attached', 'attached', 'Enclosed', 'enclosed', 'Enclosure', 'enclosure'] for word in matchwords - # en attachmentTranslatedRegExp = new RegExp("\\W#{word}\\W", 'i') - - # remove blockquote, check only the unquoted content - return word if message.replace(/(
.*<\/blockquote>)/g, "").match(attachmentTranslatedRegExp) + return word if text.match(attachmentTranslatedRegExp) # user locale attachmentTranslated = App.i18n.translateContent(word) attachmentTranslatedRegExp = new RegExp("\\W#{attachmentTranslated}\\W", 'i') - - # remove blockquote, check only the unquoted content - return attachmentTranslated if message.replace(/(
.*<\/blockquote>)/g, "").match(attachmentTranslatedRegExp) + return attachmentTranslated if text.match(attachmentTranslatedRegExp) false # human readable file size diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index acb98b33c..5b3bd77c3 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -1282,7 +1282,17 @@ test("check check attachment reference", function() { verify = App.Utils.checkAttachmentReference(message) equal(verify, result) - message = '
Hi Test,
On Monday, 22 July 2019, 14:07:54, Test User wrote:

Test attachment
' + 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) + + message = '
Hi Test,
cite attachment
' + result = false + verify = App.Utils.checkAttachmentReference(message) + equal(verify, result) + + message = '
Hi Test,
ecxgmail_quote attachment
' result = false verify = App.Utils.checkAttachmentReference(message) equal(verify, result)