diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee
index 3d506bed1..39b8105d8 100644
--- a/app/assets/javascripts/app/lib/app_post/utils.coffee
+++ b/app/assets/javascripts/app/lib/app_post/utils.coffee
@@ -795,8 +795,8 @@ class App.Utils
try content = $('
').html(message)
catch e then content = $('').html('' + message + '
')
- # ignore mail structures of case Ticket#1085048
- return message if content.find("div:first span:contains('CAUTION:')").css('color') == 'rgb(156, 101, 0)'
+ # Invalid html signature detection for exchange warning boxes #3571
+ return message if content.find("div:first:contains('CAUTION:')").length > 0
content.contents().each (index, node) ->
text = $(node).text()
diff --git a/lib/signature_detection.rb b/lib/signature_detection.rb
index 2bb62e40c..82d1d530b 100644
--- a/lib/signature_detection.rb
+++ b/lib/signature_detection.rb
@@ -47,6 +47,9 @@ returns
.map { |l| l.sub(%r{^.}, '') }
.first(10).join("\n")
+ # Invalid html signature detection for exchange warning boxes #3571
+ next if match_content.include?('CAUTION:')
+
# Add this substring to the signature_candidates hash and increment its match score
signature_candidates[match_content] += 1
end
diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js
index c44b0c9d2..c45278a76 100644
--- a/public/assets/tests/html_utils.js
+++ b/public/assets/tests/html_utils.js
@@ -1083,12 +1083,18 @@ test("identify signature by HTML", function() {
result = App.Utils.signatureIdentifyByHtml(message)
equal(result, should)
- // ignore mail structures of case Ticket#1085048
+ // Invalid html signature detection for exchange warning boxes #3571
message = 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
'
should = 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
'
result = App.Utils.signatureIdentifyByHtml(message)
equal(result, should)
+ // Invalid html signature detection for exchange warning boxes #3571
+ message = 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
'
+ should = 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
'
+ result = App.Utils.signatureIdentifyByHtml(message)
+ equal(result, should)
+
// Gmail via Safari on MacOS 10.12
message = 'Reply with gmail via Safari on MacOS 10.12
\
\
diff --git a/spec/lib/signature_detection_spec.rb b/spec/lib/signature_detection_spec.rb
index 53b130746..bc1dacff9 100644
--- a/spec/lib/signature_detection_spec.rb
+++ b/spec/lib/signature_detection_spec.rb
@@ -107,6 +107,21 @@ RSpec.describe SignatureDetection do
expect { described_class.find_signature(messages) }.not_to raise_error
end
end
+
+ context 'when message contains exchange warning (#3571)' do
+ let(:content_type) { 'text/html' }
+ let(:messages) do
+ [
+ { content: '
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
', content_type: 'text/html' },
+ { content: 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
', content_type: 'text/html' },
+ { content: 'CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
', content_type: 'text/html' },
+ ]
+ end
+
+ it 'does not detect the warning information as signature' do
+ expect(described_class.find_signature(messages)).to eq(nil)
+ end
+ end
end
describe '.find_signature_line' do