diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
index 70835c021..3b3cb1052 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
@@ -296,6 +296,7 @@ class EmailReply extends App.Controller
App.Utils.htmlStrip(signature)
if signaturePosition is 'top'
body.prepend(signature)
+ body.prepend('
')
else
body.append(signature)
ui.$('[data-name=body]').replaceWith(body)
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
index e28119972..7c1f39ca3 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
@@ -148,13 +148,13 @@ class ArticleViewItem extends App.ObserverController
body.splice(article.preferences.signature_detection, 0, signatureDetected)
body = body.join('
')
else
- body = App.Utils.signatureIdentify(body)
+ body = App.Utils.signatureIdentifyByHtml(body)
article['html'] = body
else
# client signature detection
bodyHtml = App.Utils.text2html(article.body)
- article['html'] = App.Utils.signatureIdentify(bodyHtml)
+ article['html'] = App.Utils.signatureIdentifyByPlaintext(bodyHtml)
# if no signature detected or within frist 25 lines, check if signature got detected in backend
if article['html'] is bodyHtml || (article.preferences && article.preferences.signature_detection < 25)
diff --git a/app/assets/javascripts/app/lib/app_post/utils.coffee b/app/assets/javascripts/app/lib/app_post/utils.coffee
index c1f8dcbdc..d199a0577 100644
--- a/app/assets/javascripts/app/lib/app_post/utils.coffee
+++ b/app/assets/javascripts/app/lib/app_post/utils.coffee
@@ -425,8 +425,8 @@ class App.Utils
else
true
- # messageWithMarker = App.Utils.signatureIdentify(message, false)
- @signatureIdentify: (message, test = false, internal = false) ->
+ # messageWithMarker = App.Utils.signatureIdentifyByPlaintext(message, false)
+ @signatureIdentifyByPlaintext: (message, test = false, internal = false) ->
textToSearch = @html2text(message)
# if we do have less then 10 lines and less then 300 chars ignore this
@@ -645,6 +645,64 @@ class App.Utils
regex = new RegExp("\>(\s{0,10}#{quote(App.Utils.htmlEscape(markers[0].line))})")
message.replace(regex, ">#{markerTemplate}\$1")
+ @isMicrosoftOffice: (message) ->
+ regex = new RegExp('-----(Ursprüngliche Nachricht|Original Message|Mensaje original|Message d\'origine|Messaggio originale|邮件原件|原始郵件)-----')
+ message.match(regex)
+
+ # messageWithMarker = App.Utils.signatureIdentifyByHtml(message)
+ @signatureIdentifyByHtml: (message) ->
+ # use the plaintext fallback method if message is composed by Microsoft Office
+ if @isMicrosoftOffice message
+ return @signatureIdentifyByPlaintext message
+
+ message_element = $($.parseHTML(message))
+ if message_element.length == 1 && $(message_element[0])?.children()?.length
+ message_element[0].innerHTML = @signatureIdentifyByHtmlHelper(message_element[0].innerHTML)
+ return message_element[0].outerHTML
+
+ @signatureIdentifyByHtmlHelper(message)
+
+ @signatureIdentifyByHtmlHelper: (message, internal = false) ->
+ # blockquotes and signature blocks are considered "dismiss nodes" and their indice will be stored
+ dismissNodes = []
+ contentNodes = []
+ res = []
+
+ isQuoteOrSignature = (el) ->
+ el = $(el)
+ tag = el.prop("tagName")
+ return true if tag is 'BLOCKQUOTE'
+ # detect Zammad's own
test 123
test 123
--
Bob Smith
" should = "test 123
test 123
--
Bob Smith
" - result = App.Utils.signatureIdentify(message, true) + result = App.Utils.signatureIdentifyByPlaintext(message, true) equal(result, should) message = "Test reply to zammad--
some test--
some testlalala
lalala
lalala
lalala
lalala
lalala
quoted content' + should = '
quoted content' + result = App.Utils.signatureIdentifyByHtml(message) + equal(result, should) + + // simple case 2 + message = '
quoted content
quoted content
quoted content
quoted content
quoted content
test email content\ +
\ +
\ +
test email content\ +
\ +
\ +
test\ + email content\ +\ +
\ +
\ +
test\ + email content\ +\ +
\ +
\ +
On 4. Sep 2018, at 15:32, Billy Zhou <bz@zammad.com> wrote:test email content
On 4. Sep 2018, at 15:32, Billy Zhou <bz@zammad.com> wrote:test email content
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Ursprüngliche Nachricht-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Ursprüngliche Nachricht-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Original Message-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Original Message-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Ursprüngliche Nachricht-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +
Reply with Office 365 (10325.20118) on Windows 10 Build 1803
\ +\ +
fett
\ +\ +
--
\ +Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany
\ +\ +
P: +49 (0) 30 55 57 160-0
\ +F: +49 (0) 30 55 57 160-99
\ +\ +\ +
Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg
\ +Managing Director: Martin Edenhofer
\ +\ +
-----Ursprüngliche Nachricht-----
Von: Billy Zhou <bz@zammad.com>
Gesendet: Dienstag, 4. September 2018 15:33
An: me@zammad.com
Betreff: test email title
\ +
test email content
\ +\ +