diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index a3e20387f..d056cd0e3 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -507,7 +507,7 @@ class App.TicketZoom extends App.Controller # set see more options setSeeMore: => - maxHeight = 480 + maxHeight = 560 @$('.textBubble-content').each( (index) -> bubble = $( @ ) diff --git a/app/assets/javascripts/app/lib/app_post/utils.js.coffee b/app/assets/javascripts/app/lib/app_post/utils.js.coffee index b23ead13f..8a7645150 100644 --- a/app/assets/javascripts/app/lib/app_post/utils.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/utils.js.coffee @@ -198,6 +198,11 @@ class App.Utils quote = (str) -> (str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&") + cleanup = (str) -> + if str.match(/(<|>|&)/) + str = str.replace(/(<|>|&).+?$/, '').trim() + str + # search for signature seperator "--\n" markers = [] searchForSeperator = (textToSearchInLines, markers) -> @@ -210,34 +215,84 @@ class App.Utils lineCount: lineCount type: 'seperator' markers.push marker + return searchForSeperator(textToSearchInLines, markers) + # search for Thunderbird + searchForThunderbird = (textToSearchInLines, markers) -> + lineCount = 0 + for line in textToSearchInLines + lineCount += 1 + + # Am 04.03.2015 um 12:47 schrieb Alf Aardvark: + if line && line.match( /^(Am)\s.{6,10}\s(um)\s.{3,10}\s(schrieb)\s.+?:/ ) + marker = + line: cleanup(line) + lineCount: lineCount + type: 'thunderbird' + markers.push marker + return + + # Thunderbird default - http://kb.mozillazine.org/Reply_header_settings + # On 01-01-2007 11:00 AM, Alf Aardvark wrote: + if line && line.match( /^(On)\s.{6,10}\s.{3,10},\s.{1,100}(wrote):/ ) + marker = + line: cleanup(line) + lineCount: lineCount + type: 'thunderbird' + markers.push marker + return + + # http://kb.mozillazine.org/Reply_header_settings + # Alf Aardvark wrote, on 01-01-2007 11:00 AM: + if line && line.match( /^.{1,100}\s(wrote),\son\s.{3,20}:/ ) + marker = + line: cleanup(line) + lineCount: lineCount + type: 'thunderbird' + markers.push marker + return + searchForThunderbird(textToSearchInLines, markers) + # search for Apple Mail - # On 01/04/15 10:55, Bob Smith wrote: searchForAppleMail = (textToSearchInLines, markers) -> lineCount = 0 for line in textToSearchInLines lineCount += 1 - if line && line.match( /^(On|Am)\s.+?\s(wrote|schrieb):/ ) + + # On 01/04/15 10:55, Bob Smith wrote: + if line && line.match( /^(On)\s.{6,10}\s.{3,10}\s.+?\s(wrote):/ ) marker = - line: line + line: cleanup(line) lineCount: lineCount type: 'apple' markers.push marker + return + + # Am 03.04.2015 um 20:58 schrieb Martin Edenhofer : + if line && line.match( /^(Am)\s.{6,10}\s(um)\s.{3,10}\s(schrieb)\s.+?:/ ) + marker = + line: cleanup(line) + lineCount: lineCount + type: 'apple' + markers.push marker + return searchForAppleMail(textToSearchInLines, markers) # search for otrs + # 25.02.2015 10:26 - edv hotline wrote: # 25.02.2015 10:26 - edv hotline schrieb: searchForOtrs = (textToSearchInLines, markers) -> lineCount = 0 for line in textToSearchInLines lineCount += 1 - if line && line.match( /^.+?\s.+?\s-\s.+?\s(wrote|schrieb):/ ) + if line && line.match( /^..{6,10}\s.{3,10}\s-\s.+?\s(wrote|schrieb):/ ) marker = - line: line + line: cleanup(line) lineCount: lineCount type: 'Otrs' markers.push marker + return searchForOtrs(textToSearchInLines, markers) # search for Ms @@ -277,12 +332,26 @@ class App.Utils foundInLines = lineCount searchForMs(textToSearchInLines, markers) + # marker template + markerTemplate = '' + + # search for zammad + #
+ if !markers || !markers[0] + regex = new RegExp( "(
)" ) + if message.match( regex ) + return message.replace( regex, "#{markerTemplate}\$1" ) + + # search for
+ #
+ if !markers || !markers[0] + regex = new RegExp( "(
)" ) + if message.match( regex ) + return message.replace( regex, "#{markerTemplate}\$1" ) + # if no marker is found, return return message if !markers || !markers[0] - # insert marker - markerTemplate = '' - # get first marker markers = _.sortBy(markers, 'lineCount') if markers[0].type is 'seperator' diff --git a/public/assets/tests/html-utils.js b/public/assets/tests/html-utils.js index ff4f24d0c..7e1209f48 100644 --- a/public/assets/tests/html-utils.js +++ b/public/assets/tests/html-utils.js @@ -544,22 +544,20 @@ test( "identify signature", function() { result = App.Utils.signatureIdentify( message, true ) // apple + // en message = "
test 123

--no not match--

Bob Smith
On 01/04/15 10:55, Bob Smith wrote:
lalala

--

some test
" should = '
test 123

--no not match--

Bob Smith
On 01/04/15 10:55, Bob Smith wrote:
lalala

--

some test
' result = App.Utils.signatureIdentify( message, true ) equal( result, should ) - message = "
test 123

--no not match--

Bob Smith
Am 01/04/15 10:55, Bob Smith schrieb:
lalala
" - should = '
test 123

--no not match--

Bob Smith
Am 01/04/15 10:55, Bob Smith schrieb:
lalala
' + // de + message = "
test 123

--no not match--

Bob Smith
Am 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:
lalala
" + should = '
test 123

--no not match--

Bob Smith
Am 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:
lalala
' result = App.Utils.signatureIdentify( message, true ) equal( result, should ) // ms - message = "
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
" - should = '
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
' - result = App.Utils.signatureIdentify( message, true ) - equal( result, should ) - + // en message = "
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
lalala
" should = '
test 123

--no not match--

Bob Smith
From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Sent: Donnerstag, 2. April 2015 10:00
lalala
' result = App.Utils.signatureIdentify( message, true ) @@ -575,6 +573,12 @@ test( "identify signature", function() { result = App.Utils.signatureIdentify( message, true ) equal( result, should ) + // de + message = "
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
" + should = '
test 123

--no not match--

Bob Smith
Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
Gesendet: Donnerstag, 2. April 2015 10:00
Betreff: lalala
' + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + message = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
" should = "
1

Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]
\n
Gesendet: Donnerstag, 2. April 2015 11:32
" result = App.Utils.signatureIdentify( message, true ) @@ -590,12 +594,38 @@ test( "identify signature", function() { result = App.Utils.signatureIdentify( message, true ) equal( result, should ) + message = "
Von: \"Johannes Nickel via Znuny Projects\" <projects@znuny.inc>
An: \"Lisa Smith\" <lisa.smith@example.com>
Gesendet: Donnerstag, 2. April 2015 10:11:12
Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]

Hallo Frau Smith,
" + should = "
Von: \"Johannes Nickel via Znuny Projects\" <projects@znuny.inc>
An: \"Lisa Smith\" <lisa.smith@example.com>
Gesendet: Donnerstag, 2. April 2015 10:11:12
Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]

Hallo Frau Smith,
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + // thunderbird + // de + message = "

Viele Grüße,
Christian

Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:
> Hallo Christian,
" + should = "

Viele Grüße,
Christian

Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:
> Hallo Christian,
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + // en - Thunderbird default - http://kb.mozillazine.org/Reply_header_settings + message = "

Viele Grüße,
Christian

On 01-01-2007 11:00 AM, Alf Aardvark wrote:
> Hallo Christian,
" + should = "

Viele Grüße,
Christian

On 01-01-2007 11:00 AM, Alf Aardvark wrote:
> Hallo Christian,
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + // en - http://kb.mozillazine.org/Reply_header_settings + message = "

Viele Grüße,
Christian

Alf Aardvark wrote, on 01-01-2007 11:00 AM:
> Hallo Christian,
" + should = "

Viele Grüße,
Christian

Alf Aardvark wrote, on 01-01-2007 11:00 AM:
> Hallo Christian,
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + // otrs + // en message = "
test 123

--no not match--

Bob Smith
01/04/15 10:55 - Bob Smith wrote:
lalala
" should = '
test 123

--no not match--

Bob Smith
01/04/15 10:55 - Bob Smith wrote:
lalala
' result = App.Utils.signatureIdentify( message, true ) equal( result, should ) + // de message = "
test 123

--no not match--

Bob Smith
01/04/15 10:55 - Bob Smith schrieb:
lalala
" should = '
test 123

--no not match--

Bob Smith
01/04/15 10:55 - Bob Smith schrieb:
lalala
' result = App.Utils.signatureIdentify( message, true ) @@ -606,6 +636,17 @@ test( "identify signature", function() { result = App.Utils.signatureIdentify( message, true ) equal( result, should ) + // zammad + message = "
test 123

--no not match--

Bob Smith
lalala
" + should = "
test 123

--no not match--

Bob Smith
lalala
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + + message = "
test 123

--no not match--

Bob Smith
lalala
" + should = "
test 123

--no not match--

Bob Smith
lalala
" + result = App.Utils.signatureIdentify( message, true ) + equal( result, should ) + }); // replace tags