Follow up - ec8b7b5be1
- Fixes #2325 - remove blockquote blocks before checking if attachment is referenced in message.
This commit is contained in:
parent
1db27646d5
commit
59f9f1a1b6
2 changed files with 19 additions and 8 deletions
|
@ -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 = $('<div>' + message + '</div>')
|
||||
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>.*<\/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>.*<\/blockquote>)/g, "").match(attachmentTranslatedRegExp)
|
||||
return attachmentTranslated if text.match(attachmentTranslatedRegExp)
|
||||
false
|
||||
|
||||
# human readable file size
|
||||
|
|
|
@ -1282,7 +1282,17 @@ test("check check attachment reference", function() {
|
|||
verify = App.Utils.checkAttachmentReference(message)
|
||||
equal(verify, result)
|
||||
|
||||
message = '<div>Hi Test,</div><div><blockquote>On Monday, 22 July 2019, 14:07:54, Test User wrote:<br><br>Test attachment<br></blockquote></div>'
|
||||
message = '<div>Hi Test,</div><div><blockquote>On Monday, 22 July 2019, 14:07:54, Test User wrote:<br><br>Test attachment <br></blockquote></div>'
|
||||
result = false
|
||||
verify = App.Utils.checkAttachmentReference(message)
|
||||
equal(verify, result)
|
||||
|
||||
message = '<div>Hi Test,</div><div><blockquote type="cite">cite attachment </blockquote></div>'
|
||||
result = false
|
||||
verify = App.Utils.checkAttachmentReference(message)
|
||||
equal(verify, result)
|
||||
|
||||
message = '<div>Hi Test,</div><div><blockquote class="ecxgmail_quote">ecxgmail_quote attachment </blockquote></div>'
|
||||
result = false
|
||||
verify = App.Utils.checkAttachmentReference(message)
|
||||
equal(verify, result)
|
||||
|
|
Loading…
Reference in a new issue