html_utils.js 181 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733
  1. window.onload = function() {
  2. // textCleanup
  3. QUnit.test("textCleanup", assert => {
  4. var source = "Some\nValue\n\n\nTest"
  5. var should = "Some\nValue\n\nTest"
  6. var result = App.Utils.textCleanup(source)
  7. assert.equal(result, should, source)
  8. source = "Some\nValue\n\n \n\n\nTest"
  9. should = "Some\nValue\n\nTest"
  10. result = App.Utils.textCleanup(source)
  11. assert.equal(result, should, source)
  12. source = "Some\n\rValue\n\r\n\r\n\rTest"
  13. should = "Some\nValue\n\nTest"
  14. result = App.Utils.textCleanup(source)
  15. assert.equal(result, should, source)
  16. source = "Some\n\rValue\n\r\n\r\n\rTest\r"
  17. should = "Some\nValue\n\nTest"
  18. result = App.Utils.textCleanup(source)
  19. assert.equal(result, should, source)
  20. source = "Some\r\nValue\r\n\r\n\r\nTest\r\n"
  21. should = "Some\nValue\n\nTest"
  22. result = App.Utils.textCleanup(source)
  23. assert.equal(result, should, source)
  24. source = "Some\r\nValue\r\n\r\n\r\n\r\n\r\n\r\nTest\r\n"
  25. should = "Some\nValue\n\nTest"
  26. result = App.Utils.textCleanup(source)
  27. assert.equal(result, should, source)
  28. source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..."
  29. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  30. result = App.Utils.textCleanup(source)
  31. assert.equal(result, should, source)
  32. });
  33. // text2html
  34. QUnit.test("text2html", assert => {
  35. var source = "Some\nValue\n\n\nTest"
  36. var should = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
  37. var result = App.Utils.text2html(source)
  38. assert.equal(result, should, source)
  39. source = "Some\nValue\n"
  40. should = "<div>Some</div><div>Value</div>"
  41. result = App.Utils.text2html(source)
  42. assert.equal(result, should, source)
  43. source = "Some\n<b>Value</b>\n"
  44. should = "<div>Some</div><div>&lt;b&gt;Value&lt;/b&gt;</div>"
  45. result = App.Utils.text2html(source)
  46. assert.equal(result, should, source)
  47. source = "> Welcome!\n> \n> Thank you for installing Zammad.\n> \n> You will find ..."
  48. should = "<div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div><div>&gt; You will find ...</div>"
  49. result = App.Utils.text2html(source)
  50. assert.equal(result, should, source)
  51. source = "Some\nValue\n"
  52. should = "<div>Some</div><div>Value</div>"
  53. result = App.Utils.text2html(source)
  54. assert.equal(result, should, source)
  55. source = "Some\rValue\r"
  56. should = "<div>Some</div><div>Value</div>"
  57. result = App.Utils.text2html(source)
  58. assert.equal(result, should, source)
  59. source = "Some\n\rValue\n\r"
  60. should = "<div>Some</div><div>Value</div>"
  61. result = App.Utils.text2html(source)
  62. assert.equal(result, should, source)
  63. source = "Some\r\nValue\r\n"
  64. should = "<div>Some</div><div>Value</div>"
  65. result = App.Utils.text2html(source)
  66. assert.equal(result, should, source)
  67. source = "Some Value 123"
  68. should = "<span>Some &nbsp; Value 123</span>"
  69. result = App.Utils.text2html(source)
  70. assert.equal(result, should, source)
  71. source = "Some\n Value\n 123"
  72. should = "<div>Some</div><div> &nbsp; Value</div><div> &nbsp; &nbsp;123</div>"
  73. result = App.Utils.text2html(source)
  74. assert.equal(result, should, source)
  75. });
  76. // htmlStrip
  77. QUnit.test("htmlStrip", assert => {
  78. var source = $('<div><br><b>lala</b></div>')
  79. var should = '<div><b>lala</b></div>'
  80. App.Utils.htmlStrip(source)
  81. assert.equal(source.get(0).outerHTML, should)
  82. source = $('<div><br><br><br><b>lala</b></div>')
  83. should = '<div><b>lala</b></div>'
  84. App.Utils.htmlStrip(source)
  85. assert.equal(source.get(0).outerHTML, should)
  86. source = $('<div><br><br><br><b>lala</b><br><br></div>')
  87. should = '<div><b>lala</b></div>'
  88. App.Utils.htmlStrip(source)
  89. assert.equal(source.get(0).outerHTML, should)
  90. source = $('<div><br><br><div><br></div><b>lala</b><br><br></div>')
  91. should = '<div><div><br></div><b>lala</b></div>'
  92. App.Utils.htmlStrip(source)
  93. assert.equal(source.get(0).outerHTML, should)
  94. });
  95. // lastLineEmpty
  96. QUnit.test("htmlLastLineEmpty", assert => {
  97. var source = $('<div><br><b>lala</b></div>')
  98. assert.equal(App.Utils.htmlLastLineEmpty(source), false)
  99. source = $('<div><br><b>lala</b><br></div>')
  100. assert.equal(App.Utils.htmlLastLineEmpty(source), true)
  101. });
  102. // html2text
  103. QUnit.test("html2text", assert => {
  104. var source = "<div>Some</div><div>Value</div><div><br></div><div>Test</div>"
  105. var should = "Some\nValue\n\nTest"
  106. var result = App.Utils.html2text(source)
  107. assert.equal(result, should, source)
  108. source = "<div>Some</div><div>Value</div>"
  109. should = "Some\nValue"
  110. result = App.Utils.html2text(source)
  111. assert.equal(result, should, source)
  112. source = "<div>Some<br/>Value</div>"
  113. should = "Some\nValue"
  114. result = App.Utils.html2text(source)
  115. assert.equal(result, should, source)
  116. source = "<div>Some &amp; &lt;Value&gt;</div>"
  117. should = "Some & <Value>"
  118. result = App.Utils.html2text(source)
  119. assert.equal(result, should, source)
  120. source = "<div>Some</div><div>&lt;b&gt;Value&lt;/b&gt;</div>"
  121. should = "Some\n<b>Value</b>"
  122. result = App.Utils.html2text(source)
  123. assert.equal(result, should, source)
  124. source = "<div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div><div>&gt; You will find ...</div>"
  125. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  126. result = App.Utils.html2text(source)
  127. assert.equal(result, should, source)
  128. source = "<div>test 123 <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
  129. should = "test 123 \n\n--\nBob Smith"
  130. result = App.Utils.html2text(source)
  131. assert.equal(result, should, source)
  132. source = "test 123 <br><br><br><br><br><br><br><br><br><br><br>--<br>Bob Smith"
  133. should = "test 123 \n\n--\nBob Smith"
  134. result = App.Utils.html2text(source)
  135. assert.equal(result, should, source)
  136. source = "<div>1<br><br><br><br><br><br><br><br><br><br></div><div>Von: Martin Edenhofer via Zammad Support [<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
  137. should = "1\n\nVon: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]\nGesendet: Donnerstag, 2. April 2015 11:32"
  138. result = App.Utils.html2text(source)
  139. assert.equal(result, should, source)
  140. source = "<div>test 123<br/>lalala<p>--</p>some test</div>"
  141. should = "test 123\nlalala\n--\nsome test"
  142. result = App.Utils.html2text(source)
  143. assert.equal(result, should, source)
  144. source = "<p><span>Was\nsoll verbessert werden:</span></p>"
  145. should = "Was soll verbessert werden:"
  146. result = App.Utils.html2text(source)
  147. assert.equal(result, should, source)
  148. // in raw format, without cleanup
  149. source = "<div>Some</div><div>1234</div>"
  150. should = "Some\n1234\n"
  151. result = App.Utils.html2text(source, true)
  152. assert.equal(result, should, source)
  153. source = "<div>Some</div><div> 1234</div>"
  154. should = "Some\n 1234\n"
  155. result = App.Utils.html2text(source, true)
  156. assert.equal(result, should, source)
  157. source = "\n\n<div>Some</div>\n<div> 1234</div>"
  158. should = "Some\n 1234\n"
  159. result = App.Utils.html2text(source, true)
  160. assert.equal(result, should, source)
  161. source = "<div>Some</div><div> 1234</div>"
  162. should = "Some\n 1234\n"
  163. result = App.Utils.html2text(source, true)
  164. assert.equal(result, should, source)
  165. source = "<div>Some</div>\n\n<div> 1234</div>\n"
  166. should = "Some\n 1234\n"
  167. result = App.Utils.html2text(source, true)
  168. assert.equal(result, should, source)
  169. source = "<div>test<br>new line<br></div>"
  170. should = "test\nnew line\n\n"
  171. result = App.Utils.html2text(source, true)
  172. assert.equal(result, should, source)
  173. source = "<p><span>Was\nsoll verbessert werden:</span></p>"
  174. should = "Was soll verbessert werden:\n"
  175. result = App.Utils.html2text(source, true)
  176. assert.equal(result, should, source)
  177. });
  178. // phoneify
  179. QUnit.test("phoneify", assert => {
  180. var source = "+1 123 123 123-123"
  181. var should = 'tel:+1123123123123'
  182. var result = App.Utils.phoneify(source)
  183. assert.equal(result, should, source)
  184. source = "+1 123 123 A 123-123<>"
  185. should = 'tel:+1123123123123'
  186. result = App.Utils.phoneify(source)
  187. assert.equal(result, should, source)
  188. source = "+1 (123) 123 123-123"
  189. should = 'tel:+1123123123123'
  190. result = App.Utils.phoneify(source)
  191. assert.equal(result, should, source)
  192. source = "+1 (123) 123 1#23-123"
  193. should = 'tel:+11231231#23123'
  194. result = App.Utils.phoneify(source)
  195. assert.equal(result, should, source)
  196. source = "+1 (123) 12*3 1#23-123"
  197. should = 'tel:+112312*31#23123'
  198. result = App.Utils.phoneify(source)
  199. assert.equal(result, should, source)
  200. source = "+1 (123) 12+3"
  201. should = 'tel:+1123123'
  202. result = App.Utils.phoneify(source)
  203. assert.equal(result, should, source)
  204. source = "+1 (123) 123 "
  205. should = 'tel:+1123123'
  206. result = App.Utils.phoneify(source)
  207. assert.equal(result, should, source)
  208. source = " +1 (123) 123 "
  209. should = 'tel:+1123123'
  210. result = App.Utils.phoneify(source)
  211. assert.equal(result, should, source)
  212. })
  213. // linkify
  214. QUnit.test("linkify", assert => {
  215. var source = "http://example.com"
  216. var should = '<a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a>'
  217. var result = App.Utils.linkify(source)
  218. assert.equal(result, should, source)
  219. source = "http://example.com?some_param=lalala"
  220. should = '<a href="http://example.com?some_param=lalala" title="http://example.com?some_param=lalala" target="_blank">http://example.com?some_param=lalala</a>'
  221. result = App.Utils.linkify(source)
  222. assert.equal(result, should, source)
  223. source = "example.com"
  224. should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
  225. result = App.Utils.linkify(source)
  226. assert.equal(result, should, source)
  227. source = "some text example.com"
  228. should = 'some text <a href="http://example.com" title="http://example.com" target="_blank">example.com</a>'
  229. result = App.Utils.linkify(source)
  230. assert.equal(result, should, source)
  231. source = "example.com some text"
  232. should = '<a href="http://example.com" title="http://example.com" target="_blank">example.com</a> some text'
  233. result = App.Utils.linkify(source)
  234. assert.equal(result, should, source)
  235. source = "test@example.com some text"
  236. should = '<a href="mailto:test@example.com" title="mailto:test@example.com">test@example.com</a> some text'
  237. result = App.Utils.linkify(source)
  238. assert.equal(result, should, source)
  239. source = "abc domain.de-@domain.de some text"
  240. should = 'abc <a href="mailto:domain.de-@domain.de" title="mailto:domain.de-@domain.de">domain.de-@domain.de</a> some text'
  241. result = App.Utils.linkify(source)
  242. assert.equal(result, should, source)
  243. /*
  244. source = "<b>example.com</b>"
  245. should = '<b><a href="http://example.com" title="http://example.com" target="_blank">http://example.com</a></b>'
  246. result = App.Utils.linkify(source)
  247. assert.equal(result, should, source)
  248. */
  249. });
  250. // htmlEscape
  251. QUnit.test("htmlEscape", assert => {
  252. var source = "<"
  253. var should = "&lt;"
  254. var result = App.Utils.htmlEscape(source)
  255. assert.equal(result, should, source)
  256. source = ">"
  257. should = "&gt;"
  258. result = App.Utils.htmlEscape(source)
  259. assert.equal(result, should, source)
  260. source = "&"
  261. should = "&amp;"
  262. result = App.Utils.htmlEscape(source)
  263. assert.equal(result, should, source)
  264. source = "&amp;"
  265. should = "&amp;amp;"
  266. result = App.Utils.htmlEscape(source)
  267. assert.equal(result, should, source)
  268. source = "&amp ;"
  269. should = "&amp;amp ;"
  270. result = App.Utils.htmlEscape(source)
  271. assert.equal(result, should, source)
  272. source = "& amp;"
  273. should = "&amp; amp;"
  274. result = App.Utils.htmlEscape(source)
  275. assert.equal(result, should, source)
  276. source = "'test'"
  277. should = "&#39;test&#39;"
  278. result = App.Utils.htmlEscape(source)
  279. assert.equal(result, should, source)
  280. source = '"test"'
  281. should = "&quot;test&quot;"
  282. result = App.Utils.htmlEscape(source)
  283. assert.equal(result, should, source)
  284. source = "<>"
  285. should = "&lt;&gt;"
  286. result = App.Utils.htmlEscape(source)
  287. assert.equal(result, should, source)
  288. source = "<&lt;>"
  289. should = "&lt;&amp;lt;&gt;"
  290. result = App.Utils.htmlEscape(source)
  291. assert.equal(result, should, source)
  292. });
  293. // htmlRemoveTags
  294. QUnit.test("htmlRemoveTags", assert => {
  295. var source = "<div>test</div>"
  296. //var should = "<div>test</div>"
  297. var should = "test"
  298. var result = App.Utils.htmlRemoveTags($(source))
  299. assert.equal(result.html(), should, source)
  300. source = "<div>test<!-- some comment --></div>"
  301. //should = "<div>test</div>"
  302. should = "test"
  303. result = App.Utils.htmlRemoveTags($(source))
  304. assert.equal(result.html(), should, source)
  305. source = "<a href=\"some_link\">some link to somewhere</a>"
  306. should = "some link to somewhere"
  307. result = App.Utils.htmlRemoveTags($(source))
  308. assert.equal(result.html(), should, source)
  309. source = "<div><a href=\"some_link\">some link to somewhere</a></div>"
  310. //should = "<div>some link to somewhere</div>"
  311. should = "some link to somewhere"
  312. result = App.Utils.htmlRemoveTags($(source))
  313. assert.equal(result.html(), should, source)
  314. source = "<div><a href=\"some_link\">some link to somewhere</a><input value=\"should not be shown\"></div>"
  315. //should = "<div>some link to somewhere</div>"
  316. should = "some link to somewhere"
  317. result = App.Utils.htmlRemoveTags($(source))
  318. assert.equal(result.html(), should, source)
  319. source = "<div><a href=\"some_link\">some link to somewhere</a> <div><hr></div> <span>123</span> <img src=\"some_image\"/></div>"
  320. //should = "<div>some link to somewhere 123 </div>"
  321. should = "some link to somewhere 123 "
  322. result = App.Utils.htmlRemoveTags($(source))
  323. assert.equal(result.html(), should, source)
  324. });
  325. // htmlRemoveRichtext
  326. QUnit.test("htmlRemoveRichtext", assert => {
  327. source = "<div><form class=\"xxx\">test 123</form><svg><use xlink:href=\"" + App.Config.get('icons_url') + "#icon-status\"></svg></div>"
  328. //should = "<div>test 123</div>"
  329. should = "test 123"
  330. result = App.Utils.htmlRemoveRichtext($(source))
  331. assert.equal(result.html(), should, source)
  332. source = "<div><textarea class=\"xxx\">test 123</textarea></div>"
  333. //should = "<div>test 123</div>"
  334. should = "test 123"
  335. result = App.Utils.htmlRemoveRichtext($(source))
  336. assert.equal(result.html(), should, source)
  337. source = "<div><p wrap=\"\">test 123</p></div>"
  338. should = "<p>test 123</p>"
  339. result = App.Utils.htmlRemoveRichtext($(source))
  340. assert.equal(result.html(), should, source)
  341. source = "<div><font size=\"3\" color=\"red\">This is some text!</font></div>"
  342. should = "This is some text!"
  343. result = App.Utils.htmlRemoveRichtext($(source))
  344. assert.equal(result.html(), should, source)
  345. should = "This is some text!"
  346. result = App.Utils.htmlRemoveRichtext(source)
  347. assert.equal(result.html(), should, source)
  348. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  349. //var should = "<div>test</div>"
  350. var should = "test"
  351. var result = App.Utils.htmlRemoveRichtext($(source))
  352. assert.equal(result.html(), should, source)
  353. source = "<div><!--[if !supportLists]--><span lang=\"DE\">1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><!--[endif]--><span lang=\"DE\">Description</span></div>"
  354. //should = "<div><span>1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span>Description</span></div>"
  355. should = "<span>1.1.1<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span>Description</span>"
  356. //should = '1.1.1 Description'
  357. result = App.Utils.htmlRemoveRichtext($(source))
  358. assert.equal(result.html(), should, source)
  359. source = "<a href=\"some_link\">some link to somewhere</a>"
  360. should = "some link to somewhere"
  361. result = App.Utils.htmlRemoveRichtext($(source))
  362. assert.equal(result.html(), should, source)
  363. source = "<div><a href=\"some_link\"></a> test </div>"
  364. //should = "<div> test </div>"
  365. should = " test "
  366. result = App.Utils.htmlRemoveRichtext($(source))
  367. assert.equal(result.html(), should, source)
  368. source = "<div><b></b> test </div>"
  369. //should = "<div> test </div>"
  370. should = " test "
  371. result = App.Utils.htmlRemoveRichtext($(source))
  372. assert.equal(result.html(), should, source)
  373. source = "<div><div><b></b> test </div></div>"
  374. //should = "<div><div> test </div></div>"
  375. should = "<div> test </div>"
  376. result = App.Utils.htmlRemoveRichtext($(source))
  377. assert.equal(result.html(), should, source)
  378. source = "<div><div><b></b> test <input value=\"should not be shown\"></div></div>"
  379. //should = "<div><div> test </div></div>"
  380. should = "<div> test </div>"
  381. result = App.Utils.htmlRemoveRichtext($(source))
  382. assert.equal(result.html(), should, source)
  383. source = "<div><div><b></b> test </div><span>123</span></div>"
  384. //should = "<div><div> test </div><span>123</span></div>"
  385. should = "<div> test </div><span>123</span>"
  386. //should = '<div> test </div>123'
  387. result = App.Utils.htmlRemoveRichtext($(source))
  388. assert.equal(result.html(), should, source)
  389. source = "<div><div class=\"xxx\" title=\"some title\" lang=\"en\"><b></b> test </div></div>"
  390. //should = "<div><div> test </div></div>"
  391. should = "<div> test </div>"
  392. result = App.Utils.htmlRemoveRichtext($(source))
  393. assert.equal(result.html(), should, source)
  394. source = "<div><textarea class=\"xxx\"> test </textarea></div>"
  395. //should = "<div> test </div>"
  396. should = " test "
  397. result = App.Utils.htmlRemoveRichtext($(source))
  398. assert.equal(result.html(), should, source)
  399. source = "<div><br></div>"
  400. //should = "<div><br></div>"
  401. should = "<br>"
  402. result = App.Utils.htmlRemoveRichtext($(source))
  403. assert.equal(result.html(), should, source)
  404. source = "<div><div class=\"xxx\"><br></div></div>"
  405. //should = "<div><div><br></div></div>"
  406. should = "<div><br></div>"
  407. result = App.Utils.htmlRemoveRichtext($(source))
  408. assert.equal(result.html(), should, source)
  409. source = "<div><form class=\"xxx\">test 123</form></div>"
  410. //should = "<div>test 123</div>"
  411. should = "test 123"
  412. result = App.Utils.htmlRemoveRichtext($(source))
  413. assert.equal(result.html(), should, source)
  414. source = "<div><div><label for=\"Ticket_888344_group_id\">Gruppe <span>*</span></label></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div><label for=\"Ticket_888344_owner_id\">Besitzer <span></span></label></div><div><div></div></div></div><div><div><div><svg><use xlink:href=\"http://localhost:3000/" + App.Config.get('icons_url') + "#icon-arrow-down\"></use></svg></div><span></span><span></span></div></div><div><div> <label for=\"Ticket_888344_state_id\">Status <span>*</span></label></div></div></div>\n"
  415. //should = "<div>test 123</div>"
  416. should = '<div>Gruppe <span>*</span></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div>Besitzer <span></span></div><div><div></div></div></div><div><div><div></div><span></span><span></span></div></div><div><div> Status <span>*</span></div></div>'
  417. result = App.Utils.htmlRemoveRichtext(source)
  418. assert.equal(result.html(), should, source)
  419. source = "<div><font size=\"3\" color=\"red\">This is some text!</font><svg><use xlink:href=\"" + App.Config.get('icons_url') + "#icon-status\"></svg></div>"
  420. should = "This is some text!"
  421. result = App.Utils.htmlRemoveRichtext($(source))
  422. assert.equal(result.html(), should, source)
  423. should = "This is some text!"
  424. result = App.Utils.htmlRemoveRichtext(source)
  425. assert.equal(result.html(), should, source)
  426. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  427. var should = "<div>test</div>"
  428. var result = App.Utils.htmlRemoveRichtext($(source))
  429. assert.equal(result.get(0).outerHTML, should, source)
  430. source = "<div><small>some link to somewhere</small></a>"
  431. should = "<div>some link to somewhere</div>"
  432. result = App.Utils.htmlRemoveRichtext($(source))
  433. assert.equal(result.get(0).outerHTML, should, source)
  434. source = "<div><div class=\"xxx\"><br></div></div>"
  435. should = "<div><div><br></div></div>"
  436. result = App.Utils.htmlRemoveRichtext($(source))
  437. assert.equal(result.get(0).outerHTML, should, source)
  438. source = "<div><table bgcolor=\"green\" aaa=\"1\"><thead><tr><th>111</th><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>key</td><td>value</td></tr></tbody></table></div>"
  439. should = "<div>111aaakeyvalue</div>"
  440. result = App.Utils.htmlRemoveRichtext(source, true)
  441. assert.equal(result.get(0).outerHTML, should, source)
  442. });
  443. // htmlCleanup
  444. QUnit.test("htmlCleanup", assert => {
  445. var source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  446. //var should = "<div>test</div>"
  447. var should = "<a href=\"test\">test</a>"
  448. var result = App.Utils.htmlCleanup($(source))
  449. assert.equal(result.html(), should, source)
  450. source = "<div><!--test comment--><a href=\"test\">test</a></div>"
  451. should = "<a href=\"test\">test</a>"
  452. result = App.Utils.htmlCleanup(source)
  453. assert.equal(result.html(), should, source)
  454. source = "some link to somewhere"
  455. should = "some link to somewhere"
  456. result = App.Utils.htmlCleanup(source)
  457. assert.equal(result.html(), should, source)
  458. source = "<li>a</li><li>b</li>"
  459. should = "<li>a</li><li>b</li>"
  460. result = App.Utils.htmlCleanup(source)
  461. assert.equal(result.html(), should, source)
  462. source = "<a href=\"some_link\">some link to somewhere</a>"
  463. should = "some link to somewhere"
  464. result = App.Utils.htmlCleanup($(source))
  465. assert.equal(result.html(), should, source)
  466. source = "<p><a href=\"some_link\">some link to somewhere</a><p>"
  467. should = "<a href=\"some_link\">some link to somewhere</a>"
  468. result = App.Utils.htmlCleanup($(source))
  469. assert.equal(result.html(), should, source)
  470. source = "<div><h1>some link to somewhere</h1></div>"
  471. should = "<h1>some link to somewhere</h1>"
  472. result = App.Utils.htmlCleanup($(source))
  473. assert.equal(result.html(), should, source)
  474. source = "<div><p id=\"123\" data-id=\"abc\">some link to somewhere</p></div>"
  475. should = "<p>some link to somewhere</p>"
  476. result = App.Utils.htmlCleanup($(source))
  477. assert.equal(result.html(), should, source)
  478. source = "<div><small>some link to somewhere</small></a>"
  479. //should = "<div>some link to somewhere</div>"
  480. should = "some link to somewhere"
  481. result = App.Utils.htmlCleanup($(source))
  482. assert.equal(result.html(), should, source)
  483. source = "<div><time>some link to somewhere</time></a>"
  484. //should = "<div>some link to somewhere</div>"
  485. should = "some link to somewhere"
  486. result = App.Utils.htmlCleanup($(source))
  487. assert.equal(result.html(), should, source)
  488. source = "<div><h1>some h1 for somewhere</h1><p><hr></p></div>"
  489. should = "<h1>some h1 for somewhere</h1><p></p><hr><p></p>"
  490. result = App.Utils.htmlCleanup($(source))
  491. assert.equal(result.html(), should, source)
  492. source = "<div><br></div>"
  493. //should = "<div><br></div>"
  494. should = "<br>"
  495. result = App.Utils.htmlCleanup($(source))
  496. assert.equal(result.html(), should, source)
  497. source = "<div><div class=\"xxx\"><br></div></div>"
  498. //should = "<div><div><br></div></div>"
  499. should = "<div><br></div>"
  500. result = App.Utils.htmlCleanup($(source))
  501. assert.equal(result.html(), should, source)
  502. source = "<div><form class=\"xxx\">test 123</form></div>"
  503. //should = "<div>test 123<br></div>"
  504. should = "test 123"
  505. result = App.Utils.htmlCleanup($(source))
  506. assert.equal(result.html(), should, source)
  507. source = "<div><form class=\"xxx\">test 123</form> some other value</div>"
  508. //should = "<div>test 123 some other value</div>"
  509. should = "test 123 some other value"
  510. result = App.Utils.htmlCleanup($(source))
  511. assert.equal(result.html(), should, source)
  512. source = "<div><form class=\"xxx\">test 123</form> some other value<input value=\"should not be shown\"></div>"
  513. //should = "<div>test 123 some other value</div>"
  514. should = "test 123 some other value"
  515. result = App.Utils.htmlCleanup($(source))
  516. assert.equal(result.html(), should, source)
  517. source = "<div><font size=\"3\" color=\"red\">This is some text!</font><svg><use xlink:href=\"" + App.Config.get('icons_url') + "#icon-status\"></svg></div>"
  518. //should = "<div>This is some text!</div>"
  519. should = "<font color=\"red\">This is some text!</font>"
  520. result = App.Utils.htmlCleanup($(source))
  521. assert.equal(result.html(), should, source)
  522. source = "<div><p>some link to somewhere from word<w:sdt>abc</w:sdt></p><o:p></o:p></a>"
  523. //should = "<div><p>some link to somewhere from wordabc</p></div>"
  524. should = '<p>some link to somewhere from wordabc</p>'
  525. result = App.Utils.htmlCleanup($(source))
  526. assert.equal(result.html(), should, source)
  527. source = "<div><div><label for=\"Ticket_888344_group_id\">Gruppe <span>*</span></label></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div><label for=\"Ticket_888344_owner_id\">Besitzer <span></span></label></div><div><div></div></div></div><div><div><div><svg><use xlink:href=\"http://localhost:3000/" + App.Config.get('icons_url') + "#icon-arrow-down\"></use></svg></div><span></span><span></span></div></div><div><div> <label for=\"Ticket_888344_state_id\">Status <span>*</span></label></div></div></div>\n"
  528. //should = "<div>test 123</div>"
  529. should = '<div>Gruppe <span>*</span></div><div><div></div></div><div><div><span></span><span></span></div></div><div><div>Besitzer <span></span></div><div><div></div></div></div><div><div><div></div><span></span><span></span></div></div><div><div> Status <span>*</span></div></div>'
  530. result = App.Utils.htmlCleanup(source)
  531. assert.equal(result.html(), should, source)
  532. source = "<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"\nxmlns:w=\"urn:schemas-microsoft-com:office:word\"\nxmlns:m=\"http://schemas.microsoft.com/office/2004/12/omml\"\nxmlns=\"http://www.w3.org/TR/REC-html40\">\n\n<head>\n<meta name=Titel content=\"\">\n<meta name=Stichwörter content=\"\">\n<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">\n<meta name=ProgId content=Word.Document>\n<meta name=Generator content=\"Microsoft Word 15\">\n<meta name=Originator content=\"Microsoft Word 15\">\n<link rel=File-List\nhref=\"file://localhost/Users/johannes/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_filelist.xml\">\n<!--[if gte mso 9]><xml>\n <o:OfficeDocumentSettings>\n <o:AllowPNG/>\n <o:PixelsPerInch>96</o:PixelsPerInch>\n </o:OfficeDocumentSettings>\n</xml><![endif]-->\n<link rel=themeData\nhref=\"file://localhost/Users/johannes/Library/Group%20Containers/UBF8T346G9.Office/msoclip1/01/clip_themedata.thmx\">\n<!--[if gte mso 9]><xml>\n <w:WordDocument>\n <w:View>Normal</w:View>\n <w:Zoom>0</w:Zoom>\n <w:TrackMoves/>\n <w:TrackFormatting/>\n <w:HyphenationZone>21</w:HyphenationZone>\n <w:PunctuationKerning/>\n <w:ValidateAgainstSchemas/>\n <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>\n <w:IgnoreMixedContent>false</w:IgnoreMixedContent>\n <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>\n <w:DoNotPromoteQF/>\n <w:LidThemeOther>DE</w:LidThemeOther>\n <w:LidThemeAsian>X-NONE</w:LidThemeAsian>\n <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>\n <w:Compatibility>\n <w:BreakWrappedTables/>\n <w:SnapToGridInCell/>\n <w:WrapTextWithPunct/>\n <w:UseAsianBreakRules/>\n <w:DontGrowAutofit/>\n <w:SplitPgBreakAndParaMark/>\n <w:EnableOpenTypeKerning/>\n <w:DontFlipMirrorIndents/>\n <w:OverrideTableStyleHps/>\n </w:Compatibility>\n <m:mathPr>\n <m:mathFont m:val=\"Cambria Math\"/>\n <m:brkBin m:val=\"before\"/>\n <m:brkBinSub m:val=\"&#45;-\"/>\n <m:smallFrac m:val=\"off\"/>\n <m:dispDef/>\n <m:lMargin m:val=\"0\"/>\n <m:rMargin m:val=\"0\"/>\n <m:defJc m:val=\"centerGroup\"/>\n <m:wrapIndent m:val=\"1440\"/>\n <m:intLim m:val=\"subSup\"/>\n <m:naryLim m:val=\"undOvr\"/>\n </m:mathPr></w:WordDocument>\n</xml><![endif]--><!--[if gte mso 9]><xml>\n <w:LatentStyles DefLockedState=\"false\" DefUnhideWhenUsed=\"false\"\n DefSemiHidden=\"false\" DefQFormat=\"false\" DefPriority=\"99\"\n LatentStyleCount=\"380\">\n <w:LsdException Locked=\"false\" Priority=\"0\" QFormat=\"true\" Name=\"Normal\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" QFormat=\"true\" Name=\"heading 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"0\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 7\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 8\"/>\n <w:LsdException Locked=\"false\" Priority=\"9\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"heading 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index 9\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 7\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 8\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"toc 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footnote text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"header\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footer\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"index heading\"/>\n <w:LsdException Locked=\"false\" Priority=\"35\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"caption\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"table of figures\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"envelope address\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"envelope return\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"footnote reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"line number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"page number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"endnote reference\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"endnote text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"table of authorities\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"macro\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"toa heading\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Bullet 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Number 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"10\" QFormat=\"true\" Name=\"Title\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Closing\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Signature\"/>\n <w:LsdException Locked=\"false\" Priority=\"1\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"Default Paragraph Font\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"List Continue 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Message Header\"/>\n <w:LsdException Locked=\"false\" Priority=\"11\" QFormat=\"true\" Name=\"Subtitle\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Salutation\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Date\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text First Indent\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text First Indent 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Heading\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Body Text Indent 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Block Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Hyperlink\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"FollowedHyperlink\"/>\n <w:LsdException Locked=\"false\" Priority=\"22\" QFormat=\"true\" Name=\"Strong\"/>\n <w:LsdException Locked=\"false\" Priority=\"20\" QFormat=\"true\" Name=\"Emphasis\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Document Map\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Plain Text\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"E-mail Signature\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Top of Form\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Bottom of Form\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal (Web)\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Acronym\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Address\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Cite\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Code\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Definition\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Keyboard\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Preformatted\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Sample\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Typewriter\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"HTML Variable\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Normal Table\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"annotation subject\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"No List\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Outline List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Simple 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Classic 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Colorful 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Columns 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Grid 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table List 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table 3D effects 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Contemporary\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Elegant\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Professional\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Subtle 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Subtle 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Web 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Balloon Text\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" Name=\"Table Grid\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Table Theme\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 2\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 3\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 4\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 5\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 6\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 7\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 8\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" UnhideWhenUsed=\"true\"\n Name=\"Note Level 9\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" Name=\"Placeholder Text\"/>\n <w:LsdException Locked=\"false\" Priority=\"1\" QFormat=\"true\" Name=\"No Spacing\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" SemiHidden=\"true\" Name=\"Revision\"/>\n <w:LsdException Locked=\"false\" Priority=\"34\" QFormat=\"true\"\n Name=\"List Paragraph\"/>\n <w:LsdException Locked=\"false\" Priority=\"29\" QFormat=\"true\" Name=\"Quote\"/>\n <w:LsdException Locked=\"false\" Priority=\"30\" QFormat=\"true\"\n Name=\"Intense Quote\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"60\" Name=\"Light Shading Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"61\" Name=\"Light List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"62\" Name=\"Light Grid Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"63\" Name=\"Medium Shading 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"64\" Name=\"Medium Shading 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"65\" Name=\"Medium List 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"66\" Name=\"Medium List 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"67\" Name=\"Medium Grid 1 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"68\" Name=\"Medium Grid 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"69\" Name=\"Medium Grid 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"70\" Name=\"Dark List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"71\" Name=\"Colorful Shading Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"72\" Name=\"Colorful List Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"73\" Name=\"Colorful Grid Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"19\" QFormat=\"true\"\n Name=\"Subtle Emphasis\"/>\n <w:LsdException Locked=\"false\" Priority=\"21\" QFormat=\"true\"\n Name=\"Intense Emphasis\"/>\n <w:LsdException Locked=\"false\" Priority=\"31\" QFormat=\"true\"\n Name=\"Subtle Reference\"/>\n <w:LsdException Locked=\"false\" Priority=\"32\" QFormat=\"true\"\n Name=\"Intense Reference\"/>\n <w:LsdException Locked=\"false\" Priority=\"33\" QFormat=\"true\" Name=\"Book Title\"/>\n <w:LsdException Locked=\"false\" Priority=\"37\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" Name=\"Bibliography\"/>\n <w:LsdException Locked=\"false\" Priority=\"39\" SemiHidden=\"true\"\n UnhideWhenUsed=\"true\" QFormat=\"true\" Name=\"TOC Heading\"/>\n <w:LsdException Locked=\"false\" Priority=\"41\" Name=\"Plain Table 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"42\" Name=\"Plain Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"43\" Name=\"Plain Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"44\" Name=\"Plain Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"45\" Name=\"Plain Table 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"40\" Name=\"Grid Table Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\" Name=\"Grid Table 1 Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\" Name=\"Grid Table 6 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\" Name=\"Grid Table 7 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"Grid Table 1 Light Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"Grid Table 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"Grid Table 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"Grid Table 4 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"Grid Table 5 Dark Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"Grid Table 6 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"Grid Table 7 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\" Name=\"List Table 1 Light\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\" Name=\"List Table 6 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\" Name=\"List Table 7 Colorful\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 1\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 2\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 3\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 4\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 5\"/>\n <w:LsdException Locked=\"false\" Priority=\"46\"\n Name=\"List Table 1 Light Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"47\" Name=\"List Table 2 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"48\" Name=\"List Table 3 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"49\" Name=\"List Table 4 Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"50\" Name=\"List Table 5 Dark Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"51\"\n Name=\"List Table 6 Colorful Accent 6\"/>\n <w:LsdException Locked=\"false\" Priority=\"52\"\n Name=\"List Table 7 Colorful Accent 6\"/>\n </w:LatentStyles>\n</xml><![endif]-->\n<style>\n<!--\n /* Font Definitions */\n@font-face\n {font-family:\"Courier New\";\n panose-1:2 7 3 9 2 2 5 2 4 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536859905 -1073711037 9 0 511 0;}\n@font-face\n {font-family:Wingdings;\n panose-1:5 0 0 0 0 0 0 0 0 0;\n mso-font-charset:2;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:0 268435456 0 0 -2147483648 0;}\n@font-face\n {font-family:\"Cambria Math\";\n panose-1:2 4 5 3 5 4 6 3 2 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536870145 1107305727 0 0 415 0;}\n@font-face\n {font-family:Calibri;\n panose-1:2 15 5 2 2 2 4 3 2 4;\n mso-font-charset:0;\n mso-generic-font-family:auto;\n mso-font-pitch:variable;\n mso-font-signature:-536870145 1073786111 1 0 415 0;}\n /* Style Definitions */\np.MsoNormal, li.MsoNormal, div.MsoNormal\n {mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-parent:\"\";\n margin:0cm;\n margin-bottom:.0001pt;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\np.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast\n {mso-style-priority:34;\n mso-style-unhide:no;\n mso-style-qformat:yes;\n mso-style-type:export-only;\n margin-top:0cm;\n margin-right:0cm;\n margin-bottom:0cm;\n margin-left:36.0pt;\n margin-bottom:.0001pt;\n mso-add-space:auto;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\n.MsoChpDefault\n {mso-style-type:export-only;\n mso-default-props:yes;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-fareast-font-family:Calibri;\n mso-fareast-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-bidi-font-family:\"Times New Roman\";\n mso-bidi-theme-font:minor-bidi;\n mso-fareast-language:EN-US;}\n@page WordSection1\n {size:595.0pt 842.0pt;\n margin:70.85pt 70.85pt 2.0cm 70.85pt;\n mso-header-margin:35.4pt;\n mso-footer-margin:35.4pt;\n mso-paper-source:0;}\ndiv.WordSection1\n {page:WordSection1;}\n /* List Definitions */\n@list l0\n {mso-list-id:240799396;\n mso-list-type:hybrid;\n mso-list-template-ids:1377200210 67567617 67567619 67567621 67567617 67567619 67567621 67567617 67567619 67567621;}\n@list l0:level1\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level2\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level3\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\n@list l0:level4\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level5\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level6\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\n@list l0:level7\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Symbol;}\n@list l0:level8\n {mso-level-number-format:bullet;\n mso-level-text:o;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:\"Courier New\";}\n@list l0:level9\n {mso-level-number-format:bullet;\n mso-level-text:;\n mso-level-tab-stop:none;\n mso-level-number-position:left;\n text-indent:-18.0pt;\n font-family:Wingdings;}\nol\n {margin-bottom:0cm;}\nul\n {margin-bottom:0cm;}\n-->\n</style>\n<!--[if gte mso 10]>\n<style>\n /* Style Definitions */\ntable.MsoNormalTable\n {mso-style-name:\"Normale Tabelle\";\n mso-tstyle-rowband-size:0;\n mso-tstyle-colband-size:0;\n mso-style-noshow:yes;\n mso-style-priority:99;\n mso-style-parent:\"\";\n mso-padding-alt:0cm 5.4pt 0cm 5.4pt;\n mso-para-margin:0cm;\n mso-para-margin-bottom:.0001pt;\n mso-pagination:widow-orphan;\n font-size:12.0pt;\n font-family:Calibri;\n mso-ascii-font-family:Calibri;\n mso-ascii-theme-font:minor-latin;\n mso-hansi-font-family:Calibri;\n mso-hansi-theme-font:minor-latin;\n mso-fareast-language:EN-US;}\n</style>\n<![endif]-->\n</head>\n\n<body bgcolor=white lang=DE style='tab-interval:35.4pt'>\n<!--StartFragment-->\n\n<p class=MsoListParagraphCxSpFirst style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 1<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 2<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]><i style='mso-bidi-font-style:normal'>Test 3<o:p></o:p></i></p>\n\n<p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]>Test 4<o:p></o:p></p>\n\n<p class=MsoListParagraphCxSpLast style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span\nstyle='font-family:Symbol;mso-fareast-font-family:Symbol;mso-bidi-font-family:\nSymbol'><span style='mso-list:Ignore'>·<span style='font:7.0pt \"Times New Roman\"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n</span></span></span><![endif]><b style='mso-bidi-font-weight:normal'>Test5<o:p></o:p></b></p>\n\n<!--EndFragment-->\n</body>\n\n</html>"
  533. should = "<ul><li>Test 1</li><li>Test 2</li><li><i>Test 3</i></li><li>Test 4</li><li><b>Test5</b></li></ul>"
  534. result = App.Utils.htmlCleanup(source)
  535. assert.equal(result.html().trim(), should, source)
  536. source = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html>\n<head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>\n <title></title>\n <meta name=\"generator\" content=\"LibreOffice 4.4.7.2 (MacOSX)\"/>\n <style type=\"text/css\">\n @page { margin: 0.79in }\n p { margin-bottom: 0.1in; line-height: 120% }\n a:link { so-language: zxx }\n </style>\n</head>\n<body lang=\"en-US\" dir=\"ltr\">\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">1.\nGehe a<b>uf </b><b>https://www.pfe</b>rdiathek.ge</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\"><br/>\n\n</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">2.\nMel<font color=\"#800000\">de Dich mit folgende</font> Zugangsdaten an:</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">Benutzer:\nme@xxx.net</p>\n<p align=\"center\" style=\"margin-bottom: 0in; line-height: 100%\">Passwort:\nxxx.</p>\n</body>\n</html>"
  537. should = "\n\n\n \n \n \n \n\n\n<p>1.\nGehe a<b>uf </b><b>https://www.pfe</b>rdiathek.ge</p>\n<p><br>\n\n</p>\n<p>2.\nMel<font color=\"#800000\">de Dich mit folgende</font> Zugangsdaten an:</p>\n<p>Benutzer:\nme@xxx.net</p>\n<p>Passwort:\nxxx.</p>\n\n"
  538. result = App.Utils.htmlCleanup(source)
  539. assert.equal(result.html(), should, source)
  540. source = "<table bgcolor=\"green\" aaa=\"1\"><thead><tr><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  541. should = "<table bgcolor=\"green\"><thead><tr><th colspan=\"2\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  542. result = App.Utils.htmlCleanup(source)
  543. assert.equal(result.get(0).outerHTML, should, source)
  544. // strip out browser-inserted (broken) link (see https://github.com/zammad/zammad/issues/2019)
  545. source = "<div><a href=\"https://example.com/#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}\">test</a></div>"
  546. should = "<a href=\"#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}\">test</a>"
  547. result = App.Utils.htmlCleanup(source)
  548. assert.equal(result.html(), should, source)
  549. source = "<table bgcolor=\"green\" aaa=\"1\" style=\"color: red\"><thead><tr style=\"margin-top: 10px\"><th colspan=\"2\" abc=\"a\" style=\"margin-top: 12px\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  550. should = "<table bgcolor=\"green\" style=\"color:red;\"><thead><tr style=\"margin-top:10px;\"><th colspan=\"2\" style=\"margin-top:12px;\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  551. result = App.Utils.htmlCleanup(source)
  552. result.get(0).outerHTML
  553. //equal(result.get(0).outerHTML, should, source) / string order is different on browsers
  554. assert.equal(result.first().attr('bgcolor'), 'green')
  555. assert.equal(result.first().attr('style'), 'color:red;')
  556. assert.equal(result.first().attr('aaa'), undefined)
  557. assert.equal(result.find('tr').first().attr('style'), 'margin-top:10px;')
  558. assert.equal(result.find('th').first().attr('colspan'), '2')
  559. assert.equal(result.find('th').first().attr('abc'), undefined)
  560. assert.equal(result.find('th').first().attr('style'), 'margin-top:12px;')
  561. source = "<table bgcolor=\"green\" aaa=\"1\" style=\"color:red; display: none;\"><thead><tr><th colspan=\"2\" abc=\"a\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  562. should = "<table bgcolor=\"green\" style=\"color:red;\"><thead><tr><th colspan=\"2\">aaa</th></tr></thead><tbody><tr><td>value</td></tr></tbody></table>"
  563. result = App.Utils.htmlCleanup(source)
  564. //equal(result.get(0).outerHTML, should, source) / string order is different on browsers
  565. assert.equal(result.first().attr('bgcolor'), 'green')
  566. assert.equal(result.first().attr('style'), 'color:red;')
  567. assert.equal(result.first().attr('aaa'), undefined)
  568. assert.equal(result.find('tr').first().attr('style'), undefined)
  569. assert.equal(result.find('th').first().attr('colspan'), '2')
  570. assert.equal(result.find('th').first().attr('abc'), undefined)
  571. assert.equal(result.find('th').first().attr('style'), undefined)
  572. // https://github.com/zammad/zammad/issues/4445
  573. source = '<meta charset=\'utf-8\'><span style="color: rgb(219, 219, 220);">This is a black font colour with white background</span>'
  574. should = '<span>This is a black font colour with white background</span>'
  575. result = App.Utils.htmlCleanup(source)
  576. assert.equal(result.html(), should, source)
  577. source = '<meta charset=\'utf-8\'><div class="article-content" style="box-sizing: border-box; color: rgb(219, 219, 220); position: relative; z-index: 1; padding: 0px 55px;"><div class="bubble-gap" style="box-sizing: border-box;"><div class="internal-border" style="box-sizing: border-box; padding: 5px; border-radius: 5px; margin: -5px;"><div class="textBubble" style="box-sizing: border-box; padding: 10px 20px; background: var(--background-article-customer); border-radius: 2px; border-color: var(--border-article-customer); box-shadow: none; position: relative;"><div class="textBubble-content" id="article-content-4" data-id="4" style="box-sizing: border-box; overflow: hidden; position: relative;"><div class="richtext-content" style="box-sizing: border-box;"><div style="box-sizing: border-box;">This is a black font colour with white background</div></div></div></div></div></div></div>'
  578. should = '<div><div><div><div><div id="article-content-4"><div><div>This is a black font colour with white background</div></div></div></div></div></div></div>'
  579. result = App.Utils.htmlCleanup(source)
  580. assert.equal(result.html(), should, source)
  581. });
  582. // wrap
  583. QUnit.test("wrap", assert => {
  584. var source = "some text"
  585. var should = 'some text'
  586. var result = App.Utils.wrap(source)
  587. assert.equal(result, should, source)
  588. source = "some text\nsome other text\n"
  589. should = "some text\nsome other text\n"
  590. result = App.Utils.wrap(source)
  591. assert.equal(result, should, source)
  592. source = "some text with some line to wrap"
  593. should = "some text with\nsome line to\nwrap"
  594. result = App.Utils.wrap(source, 14)
  595. assert.equal(result, should, source)
  596. source = "some text\nsome other text\n"
  597. should = "some text\nsome other text\n"
  598. result = App.Utils.wrap(source)
  599. assert.equal(result, should, source)
  600. source = "1234567890 1234567890 1234567890 1234567890"
  601. should = "1234567890 1234567890 1234567890 1234567890"
  602. result = App.Utils.wrap(source)
  603. assert.equal(result, should, source)
  604. source = "123456789012 123456789012 123456789012"
  605. should = "123456789012\n123456789012\n123456789012"
  606. result = App.Utils.wrap(source, 14)
  607. assert.equal(result, should, source)
  608. });
  609. // remove empty lines
  610. QUnit.test("remove empty lines", assert => {
  611. var source = "\ntest 123\n"
  612. var should = "test 123\n"
  613. var result = App.Utils.removeEmptyLines(source)
  614. assert.equal(result, should, source)
  615. source = "\ntest\n\n123\n"
  616. should = "test\n123\n"
  617. result = App.Utils.removeEmptyLines(source)
  618. assert.equal(result, should, source)
  619. });
  620. // quote
  621. QUnit.test("quote", assert => {
  622. var source = "some text"
  623. var should = '> some text'
  624. var result = App.Utils.quote(source)
  625. assert.equal(result, should, source)
  626. source = "some text\nsome other text\n"
  627. should = "> some text\n> some other text"
  628. result = App.Utils.quote(source)
  629. assert.equal(result, should, source)
  630. source = "\n\nsome text\nsome other text\n \n"
  631. should = "> some text\n> some other text"
  632. result = App.Utils.quote(source)
  633. assert.equal(result, should, source)
  634. source = "Welcome!\n\nThank you for installing Zammad.\n\nYou will find ..."
  635. should = "> Welcome!\n>\n> Thank you for installing Zammad.\n>\n> You will find ..."
  636. result = App.Utils.quote(source)
  637. assert.equal(result, should, source)
  638. source = "Welcome! Thank you for installing Zammad. You will find ..."
  639. should = "> Welcome! Thank you\n> for installing\n> Zammad. You will\n> find ..."
  640. result = App.Utils.quote(source, 20)
  641. assert.equal(result, should, source)
  642. });
  643. // check signature
  644. QUnit.test("check signature", assert => {
  645. var message = "<div>test 123 </div>"
  646. var signature = '<div>--<br>Some Signature<br>some department</div>'
  647. var result = App.Utils.signatureCheck(message, signature)
  648. assert.equal(result, true)
  649. message = "<div>test 123 <div>--<br>Some Signature<br>some department\n</div></div>"
  650. signature = '<div>--<br>Some Signature<br>some department</div>'
  651. result = App.Utils.signatureCheck(message, signature)
  652. assert.equal(result, false)
  653. message = "<div>test 123 <div>--<br>Some Signature\n<br>some department\n</div></div>"
  654. signature = '<div>--<br>Some Signature<br>some department</div>'
  655. result = App.Utils.signatureCheck(message, signature)
  656. assert.equal(result, false)
  657. message = "<div>test 123 <div>--<p>Some Signature</p>\n<p><div>some department</div>\n</p>\n</div></div>"
  658. signature = '<div>--<br>Some Signature<br>some department</div>'
  659. result = App.Utils.signatureCheck(message, signature)
  660. assert.equal(result, false)
  661. message = ""
  662. signature = '<div>--<br>Some Signature<br>some department</div>'
  663. result = App.Utils.signatureCheck(message, signature)
  664. assert.equal(result, true)
  665. message = ""
  666. signature = "--\nSome Signature\nsome department"
  667. result = App.Utils.signatureCheck(message, signature)
  668. assert.equal(result, true)
  669. });
  670. QUnit.test('remove signature', assert => {
  671. var message = '<div>test 123 </div>'
  672. var should = '<div>test 123 </div>'
  673. var result = App.Utils.signatureRemoveByHtml(message)
  674. assert.equal(result, should)
  675. var message = '<div>test 123 </div><br>'
  676. var should = '<div>test 123 </div><br>'
  677. var result = App.Utils.signatureRemoveByHtml(message)
  678. assert.equal(result, should)
  679. var message = 'test 123'
  680. var should = 'test 123'
  681. var result = App.Utils.signatureRemoveByHtml(message)
  682. assert.equal(result, should)
  683. var message = '<div>test 123 <div data-signature="true" data-signature-id="1">Test Admin Agent<br>-----</div></div>'
  684. var should = '<div>test 123 </div>'
  685. var result = App.Utils.signatureRemoveByHtml(message)
  686. assert.equal(result, should)
  687. var message = '<div>test 123 <br><div data-signature="true" data-signature-id="1">Test Admin Agent<br>-----</div></div>'
  688. var should = '<div>test 123 </div>'
  689. var result = App.Utils.signatureRemoveByHtml(message)
  690. assert.equal(result, should)
  691. var message = '<div>test 123 <br><br><div data-signature="true" data-signature-id="1">Test Admin Agent<br>-----</div></div>'
  692. var should = '<div>test 123 </div>'
  693. var result = App.Utils.signatureRemoveByHtml(message)
  694. assert.equal(result, should)
  695. var message = 'test 123<br><div data-signature="true" data-signature-id="1">Test Admin Agent<br>-----</div>'
  696. var should = 'test 123'
  697. var result = App.Utils.signatureRemoveByHtml(message)
  698. assert.equal(result, should)
  699. })
  700. // identify signature
  701. QUnit.test("identify signature by plaintext", assert => {
  702. var message = "<div>test 123 </div>"
  703. var should = '<div>test 123 </div>'
  704. var result = App.Utils.signatureIdentifyByPlaintext(message)
  705. assert.equal(result, should)
  706. message = "<div>test 123 <br/>--<br/>Bob Smith</div>"
  707. should = '<div>test 123 <br/>--<br/>Bob Smith</div>'
  708. result = App.Utils.signatureIdentifyByPlaintext(message)
  709. assert.equal(result, should)
  710. message = "<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/>--<br/>Bob Smith</div>"
  711. should = '<div>test 123 <br/>1<br/>2<br/>3<br/>4<br/>5<br/>6<br/>7<br/>8<br/>9<br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
  712. result = App.Utils.signatureIdentifyByPlaintext(message)
  713. assert.equal(result, should)
  714. message = "<div>test 123 <br/><br/>--no not match--<br/>--<br/>Bob Smith</div>"
  715. should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span>--<br/>Bob Smith</div>'
  716. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  717. assert.equal(result, should)
  718. message = "<div>test 123 <br/><br/>--no not match--<br/> -- <br/>Bob Smith</div>"
  719. should = '<div>test 123 <br/><br/>--no not match--<br/><span class="js-signatureMarker"></span> -- <br/>Bob Smith</div>'
  720. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  721. assert.equal(result, should)
  722. message = "<div>test 123 <br/><br/>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>"
  723. should = '<div>test 123 <br/><br/><span class="js-signatureMarker"></span>--<br/>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
  724. //should = '<div>test 123 <br><br><br><br><br><br><br><br><br><br><br><span class="js-signatureMarker"></span>--<br>Bob Smith<br/><br/><br/><br/><br/>--<br/>Bob Smith</div>'
  725. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  726. assert.equal(result, should)
  727. message = "<div>test 123</div><div>test 123</div><div>--</div><div>Bob Smith</div>"
  728. should = "<div>test 123</div><div>test 123</div><div><span class=\"js-signatureMarker\"></span>--</div><div>Bob Smith</div>"
  729. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  730. assert.equal(result, should)
  731. message = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span>--</span></p><p><span>Bob Smith</span></p><div></div>"
  732. should = "<p><span>test 123</span></p><p><span>test 123</span></p><p><span><span class=\"js-signatureMarker\"></span>--</span></p><p><span>Bob Smith</span></p><div></div>"
  733. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  734. assert.equal(result, should)
  735. message = "Test reply to zammad<br><br>Am 24.10.2016 18:55 schrieb &quot;Android Support&quot; &lt;android-support@example.com&gt;:<br><br>&gt; <u></u><br>&gt; Sehr geehrte Damen"
  736. should = "Test reply to zammad<br><br><span class=\"js-signatureMarker\"></span>Am 24.10.2016 18:55 schrieb &quot;Android Support&quot; &lt;android-support@example.com&gt;:<br><br>&gt; <u></u><br>&gt; Sehr geehrte Damen"
  737. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  738. assert.equal(result, should)
  739. message = "<br>&lt; On 20 Oct 2016, at 12:23, Martin Edenhofer via Zammad Helpdesk wrote:<br>"
  740. should = "<br><span class=\"js-signatureMarker\"></span>&lt; On 20 Oct 2016, at 12:23, Martin Edenhofer via Zammad Helpdesk wrote:<br>"
  741. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  742. assert.equal(result, should)
  743. // apple
  744. // en
  745. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>"
  746. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>On 01/04/15 10:55, Bob Smith wrote:<br/>lalala<p>--</p>some test</div>'
  747. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  748. assert.equal(result, should)
  749. // de
  750. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 03.04.2015 um 20:58 schrieb Bob Smith &lt;bob@example.com&gt;:<br/>lalala</div>"
  751. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Am 03.04.2015 um 20:58 schrieb Bob Smith &lt;bob@example.com&gt;:<br/>lalala</div>'
  752. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  753. assert.equal(result, should)
  754. // ms
  755. // en
  756. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>"
  757. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>lalala</div>'
  758. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  759. assert.equal(result, should)
  760. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>"
  761. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>Subject: lalala</div>'
  762. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  763. assert.equal(result, should)
  764. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>"
  765. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>From: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Sent: Donnerstag, 2. April 2015 10:00<br/>1<br/>2<br/>3<br/>4<br/>4<br/>Subject: lalala</div>'
  766. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  767. assert.equal(result, should)
  768. // de
  769. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Von: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>"
  770. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Von: Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Gesendet: Donnerstag, 2. April 2015 10:00<br/>Betreff: lalala</div>'
  771. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  772. assert.equal(result, should)
  773. message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Zammad Support [<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
  774. should = "<div>1<br><br></div><div>Von: Martin Edenhofer via Zammad Support [<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div>"
  775. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  776. assert.equal(result, should)
  777. message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Zammad Support [<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
  778. should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Zammad Support [<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>]</div>\n<div>Gesendet: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
  779. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  780. assert.equal(result, should)
  781. message = "<div>1<br><br></div><div>Von: Martin Edenhofer via Zammad Support &lt;<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>&gt;</div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
  782. should = "<div>1<br><br></div><div><span class=\"js-signatureMarker\"></span>Von: Martin Edenhofer via Zammad Support &lt;<a href=\"mailto:support@zammad.inc\" title=\"mailto:support@zammad.inc\" target=\"_blank\">mailto:support@zammad.inc</a>&gt;</div>\n<div>An: somebody</div><div>Datum: Donnerstag, 2. April 2015 11:32</div><div>Betreff: lalala</div>"
  783. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  784. assert.equal(result, should)
  785. message = "<div>Von: &quot;Johannes Nickel via Zammad Projects&quot; &lt;<a href=\"mailto:projects@zammad.inc\" title=\"mailto:projects@zammad.inc\">projects@zammad.inc</a>&gt;</div><div>An: \"Lisa Smith\" &lt;<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>&gt;</div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
  786. should = "<div><span class=\"js-signatureMarker\"></span>Von: &quot;Johannes Nickel via Zammad Projects&quot; &lt;<a href=\"mailto:projects@zammad.inc\" title=\"mailto:projects@zammad.inc\">projects@zammad.inc</a>&gt;</div><div>An: \"Lisa Smith\" &lt;<a href=\"mailto:lisa.smith@example.com\" title=\"mailto:lisa.smith@example.com\">lisa.smith@example.com</a>&gt;</div><div>Gesendet: Donnerstag, 2. April 2015 10:11:12</div><div>Betreff: Angebot Redundanz / Paket mit Silver Subscription [Ticket#424242]</div><div><br></div><div>Hallo Frau Smith,</div>"
  787. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  788. assert.equal(result, should)
  789. message = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div>&gt; On 07 Oct 2015, at 11:55, Johannes Smith &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>&gt;&gt; wrote:</div><div>&gt;</div><div>&gt; Hi,</div><div>&gt;</div><div>&gt; assert.OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
  790. should = "<div>Hi Johannes,</div><div><br></div><div>das Angebot für den halben Tag bitte an uns.</div><div>Der Termin hat sich jetzt auf 10-12 Uhr verschoben, hab ich dir weitergeleitet.</div><div><br></div><div>Viele Grüße</div><div>Max</div><div><br></div><div><span class=\"js-signatureMarker\"></span>&gt; On 07 Oct 2015, at 11:55, Johannes Smith &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>smith@example.com</a> &lt;<a href=mailto:smith@example.com title=mailto:smith@example.com target=_blank>mailto:smith@example.com</a>&gt;&gt; wrote:</div><div>&gt;</div><div>&gt; Hi,</div><div>&gt;</div><div>&gt; assert.OK. Wer kriegt das Angebot? Ist das wirklich nur ein halber Tag?</div></div>"
  791. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  792. assert.equal(result, should)
  793. message = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei&nbsp;<span style=\"line-height: 1.45; background-color: initial;\">&lt;ABC_CONFIG_Home&gt;/war/log/ITSMChangeCounter.log &nbsp;befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://zammad.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
  794. should = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei&nbsp;<span style=\"line-height: 1.45; background-color: initial;\">&lt;ABC_CONFIG_Home&gt;/war/log/ITSMChangeCounter.log &nbsp;befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://zammad.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
  795. result = App.Utils.signatureIdentifyByPlaintext(message, true, true)
  796. assert.equal(result, should)
  797. message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  798. should = "Dear Mr. Smith, nice to read you,<div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  799. result = App.Utils.signatureIdentifyByPlaintext(message, true, true)
  800. assert.equal(result, should)
  801. message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  802. should = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\">&nbsp; Thorsten Smith\n<br>\n<br>--\n</div></div>"
  803. result = App.Utils.signatureIdentifyByPlaintext(message, false, true)
  804. assert.equal(result, should)
  805. // fr
  806. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>De : Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>"
  807. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>De : Martin Edenhofer via Zammad Support [mailto:support@zammad.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>'
  808. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  809. assert.equal(result, should)
  810. // thunderbird
  811. // de
  812. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Zammad Sales:</div><div>&gt; Hallo Christian,</div>"
  813. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Zammad Sales:</div><div>&gt; Hallo Christian,</div>"
  814. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  815. assert.equal(result, should)
  816. // en - Thunderbird default - http://kb.mozillazine.org/Reply_header_settings
  817. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>&gt; Hallo Christian,</div>"
  818. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>On 01-01-2007 11:00 AM, Alf Aardvark wrote:</div><div>&gt; Hallo Christian,</div>"
  819. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  820. assert.equal(result, should)
  821. // en - http://kb.mozillazine.org/Reply_header_settings
  822. message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>&gt; Hallo Christian,</div>"
  823. should = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div><span class=\"js-signatureMarker\"></span>Alf Aardvark wrote, on 01-01-2007 11:00 AM:</div><div>&gt; Hallo Christian,</div>"
  824. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  825. assert.equal(result, should)
  826. // otrs
  827. // en
  828. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>"
  829. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith wrote:<br/>lalala</div>'
  830. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  831. assert.equal(result, should)
  832. // de
  833. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>"
  834. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>01/04/15 10:55 - Bob Smith schrieb:<br/>lalala</div>'
  835. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  836. assert.equal(result, should)
  837. message = "<div>test 123 <br/><br/></div><div>24.02.2015 14:20 - Roy Kaldung via Zammad Sales schrieb: &nbsp;</div>"
  838. should = "<div>test 123 <br/><br/></div><div><span class=\"js-signatureMarker\"></span>24.02.2015 14:20 - Roy Kaldung via Zammad Sales schrieb: &nbsp;</div>"
  839. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  840. assert.equal(result, should)
  841. // zammad
  842. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
  843. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"5\">lalala</div></div>"
  844. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  845. assert.equal(result, should)
  846. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote type=\"cite\">lalala</blockquote></div>"
  847. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote type=\"cite\">lalala</blockquote></div>"
  848. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  849. assert.equal(result, should)
  850. // gmail
  851. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
  852. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"ecxgmail_quote\">lalala</blockquote></div>"
  853. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  854. assert.equal(result, should)
  855. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
  856. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span><blockquote class=\"gmail_quote\">lalala</blockquote></div>"
  857. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  858. assert.equal(result, should)
  859. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Am 24. Dezember 2015 um 07:45 schrieb kathrine &lt;kathrine@example.com&gt;:<br/>lalala</div>"
  860. should = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class=\"js-signatureMarker\"></span>Am 24. Dezember 2015 um 07:45 schrieb kathrine &lt;kathrine@example.com&gt;:<br/>lalala</div>"
  861. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  862. assert.equal(result, should)
  863. // word 14
  864. // en
  865. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith wrote:<br/>lalala</div>"
  866. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith wrote:<br/>lalala</div>'
  867. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  868. assert.equal(result, should)
  869. // de
  870. message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>Bob Smith schrieb:<br/>lalala</div>"
  871. should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>Bob Smith schrieb:<br/>lalala</div>'
  872. result = App.Utils.signatureIdentifyByPlaintext(message, true)
  873. assert.equal(result, should)
  874. });
  875. QUnit.test("identify signature by HTML", assert => {
  876. var message = "<div>test 123 </div>"
  877. var should = message
  878. var result = App.Utils.signatureIdentifyByHtml(message)
  879. assert.equal(result, should)
  880. // test if, according to jQuery, invalid HTML does not cause a a crash
  881. // https://github.com/zammad/zammad/issues/3393
  882. message = "<td></td><table></table><div>test 123 </div>"
  883. should = message
  884. result = App.Utils.signatureIdentifyByHtml(message)
  885. assert.equal(result, should)
  886. // simple case 1
  887. message = '<div>actual content</div><blockquote>quoted content</blockquote>'
  888. should = '<div>actual content</div><span class="js-signatureMarker"></span><blockquote>quoted content</blockquote>'
  889. result = App.Utils.signatureIdentifyByHtml(message)
  890. assert.equal(result, should)
  891. // simple case 2
  892. message = '<div>actual content</div><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  893. should = '<div>actual content</div><span class="js-signatureMarker"></span><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  894. result = App.Utils.signatureIdentifyByHtml(message)
  895. assert.equal(result, should)
  896. // simple case 3
  897. message = '<div>actual content</div><blockquote>quoted content</blockquote><br><div>actual content 2</div>'
  898. should = message
  899. result = App.Utils.signatureIdentifyByHtml(message)
  900. assert.equal(result, should)
  901. // simple case 4
  902. message = ' content 0 <div>content 1</div> content 2 <blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  903. should = ' content 0 <div>content 1</div> content 2 <span class="js-signatureMarker"></span><blockquote>quoted content</blockquote><br><div><br></div><div><br> </div>'
  904. result = App.Utils.signatureIdentifyByHtml(message)
  905. assert.equal(result, should)
  906. // Invalid html signature detection for exchange warning boxes #3571
  907. message = '<div><span style="color:#9c6500;">CAUTION:</span> 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.</div><br><div><p>actual content</p><div><p>actual content 2</p></div><p>&nbsp;</p><div><p>actual quote</p></div><div><blockquote><p>actual quote</p></blockquote></div><div><p>&nbsp;</p></div><p>&nbsp;</p></div></div>'
  908. should = '<div><span style="color:#9c6500;">CAUTION:</span> 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.</div><br><div><p>actual content</p><div><p>actual content 2</p></div><p>&nbsp;</p><div><p>actual quote</p></div><div><blockquote><p>actual quote</p></blockquote></div><div><p>&nbsp;</p></div><p>&nbsp;</p></div></div>'
  909. result = App.Utils.signatureIdentifyByHtml(message)
  910. assert.equal(result, should)
  911. // Invalid html signature detection for exchange warning boxes #3571
  912. message = '<div>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.</div><br><div><p>actual content</p><div><p>actual content 2</p></div><p>&nbsp;</p><div><p>actual quote</p></div><div><blockquote><p>actual quote</p></blockquote></div><div><p>&nbsp;</p></div><p>&nbsp;</p></div></div>'
  913. should = '<div>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.</div><br><div><p>actual content</p><div><p>actual content 2</p></div><p>&nbsp;</p><div><p>actual quote</p></div><div><blockquote><p>actual quote</p></blockquote></div><div><p>&nbsp;</p></div><p>&nbsp;</p></div></div>'
  914. result = App.Utils.signatureIdentifyByHtml(message)
  915. assert.equal(result, should)
  916. // Gmail via Safari on MacOS 10.12
  917. message = '<div dir="ltr">Reply with <b>gmail</b> via Safari on MacOS 10.12</div><br>\
  918. <div>\
  919. <div dir="ltr">Am Mi., 5. Sep. 2018 um 09:22 Uhr schrieb Billy Zhou &lt;bz@zammad.com&gt;:<br>\
  920. </div>\
  921. <blockquote>test email content<br>\
  922. <br>\
  923. </blockquote>\
  924. </div>'
  925. should = '<div dir="ltr">Reply with <b>gmail</b> via Safari on MacOS 10.12</div><br>\
  926. <span class=\"js-signatureMarker\"></span><div>\
  927. <div dir="ltr">Am Mi., 5. Sep. 2018 um 09:22 Uhr schrieb Billy Zhou &lt;bz@zammad.com&gt;:<br>\
  928. </div>\
  929. <blockquote>test email content<br>\
  930. <br>\
  931. </blockquote>\
  932. </div>'
  933. result = App.Utils.signatureIdentifyByHtml(message)
  934. assert.equal(result, should)
  935. // Yahoo Mail via Safari on MacOS 10.12
  936. message = '<div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1536132243868_2594"><span id="yui_3_16_0_ym19_1_1536132243868_2593">Reply with <b id="yui_3_16_0_ym19_1_1536132243868_2597">Yahoo Mail</b> via Safari on MacOS 10.12</span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Billy Zhou &lt;bz@zammad.com&gt; schrieb am 9:08 Mittwoch, 5.September 2018:<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">test email content<br></div><div dir="ltr"><br></div><br><br></div> </div> </div> </div></div>'
  937. should = '<div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1536132243868_2594"><span id="yui_3_16_0_ym19_1_1536132243868_2593">Reply with <b id="yui_3_16_0_ym19_1_1536132243868_2597">Yahoo Mail</b> via Safari on MacOS 10.12</span></div> <div class="qtdSeparateBR"><br><br></div><span class="js-signatureMarker"></span><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Billy Zhou &lt;bz@zammad.com&gt; schrieb am 9:08 Mittwoch, 5.September 2018:<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">test email content<br></div><div dir="ltr"><br></div><br><br></div> </div> </div> </div></div>'
  938. result = App.Utils.signatureIdentifyByHtml(message)
  939. assert.equal(result, should)
  940. // Thunderbird 52 on MacOS 10.12
  941. message = 'Reply with <b>Thunderbird 52</b> on MacOS 10.12<br>\
  942. <br>\
  943. <div class="moz-cite-prefix">Am 04.09.18 um 15:32 schrieb Billy\
  944. Zhou:<br>\
  945. </div>\
  946. <blockquote type="cite"\
  947. cite="mid:da18ed01-b187-a383-bfe7-72663cf82a83@zammad.com">test\
  948. email content\
  949. <br>\
  950. <br>\
  951. </blockquote>\
  952. <br>'
  953. should = 'Reply with <b>Thunderbird 52</b> on MacOS 10.12<br>\
  954. <br>\
  955. <div class="moz-cite-prefix">Am 04.09.18 um 15:32 schrieb Billy\
  956. Zhou:<br>\
  957. </div>\
  958. <span class=\"js-signatureMarker\"></span><blockquote type="cite" cite="mid:da18ed01-b187-a383-bfe7-72663cf82a83@zammad.com">test\
  959. email content\
  960. <br>\
  961. <br>\
  962. </blockquote>\
  963. <br>'
  964. result = App.Utils.signatureIdentifyByHtml(message)
  965. assert.equal(result, should)
  966. // Apple Mail on MacOS 10
  967. message = '<div class="">Reply by <b class="">Apple Mail</b> on MacOS 10.</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 4. Sep 2018, at 15:32, Billy Zhou &lt;<a href="mailto:bz@zammad.com" class="">bz@zammad.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">test email content<br class=""><br class=""></div></div></blockquote></div><br class="">'
  968. should = '<div class="">Reply by <b class="">Apple Mail</b> on MacOS 10.</div><div class=""><br class=""></div><br class=""><span class=\"js-signatureMarker\"></span><div><blockquote type="cite" class=""><div class="">On 4. Sep 2018, at 15:32, Billy Zhou &lt;<a href="mailto:bz@zammad.com" class="">bz@zammad.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">test email content<br class=""><br class=""></div></div></blockquote></div><br class="">'
  969. result = App.Utils.signatureIdentifyByHtml(message)
  970. assert.equal(result, should)
  971. // Office 365 (10325.20118) on Windows 10 Build 1803
  972. // With German marker: -----Ursprüngliche Nachricht-----
  973. // Using fallback to signatureIdentifyByPlaintext
  974. message = '<div>\
  975. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  976. <p> </p>\
  977. <p><b>fett</b></p>\
  978. <p> </p>\
  979. <span class="js-signatureMarker"></span><p>--</p>\
  980. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  981. <p> </p>\
  982. <p>P: +49 (0) 30 55 57 160-0</p>\
  983. <p>F: +49 (0) 30 55 57 160-99</p>\
  984. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  985. <p> </p>\
  986. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  987. <p>Managing Director: Martin Edenhofer</p>\
  988. <p> </p>\
  989. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  990. <p> </p>\
  991. <p>test email content</p>\
  992. <p> </p>\
  993. </div>'
  994. should = '<div>\
  995. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  996. <p> </p>\
  997. <p><b>fett</b></p>\
  998. <p> </p>\
  999. <span class="js-signatureMarker"></span><p><span class=\"js-signatureMarker\"></span>--</p>\
  1000. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1001. <p> </p>\
  1002. <p>P: +49 (0) 30 55 57 160-0</p>\
  1003. <p>F: +49 (0) 30 55 57 160-99</p>\
  1004. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1005. <p> </p>\
  1006. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1007. <p>Managing Director: Martin Edenhofer</p>\
  1008. <p> </p>\
  1009. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1010. <p> </p>\
  1011. <p>test email content</p>\
  1012. <p> </p>\
  1013. </div>'
  1014. result = App.Utils.signatureIdentifyByHtml(message)
  1015. assert.equal(result, should)
  1016. // Office 365 (10325.20118) on Windows 10 Build 1803
  1017. // With English marker: -----Original Message-----
  1018. // Using fallback to signatureIdentifyByPlaintext
  1019. message = '<div>\
  1020. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1021. <p> </p>\
  1022. <p><b>fett</b></p>\
  1023. <p> </p>\
  1024. <span class="js-signatureMarker"></span><p>--</p>\
  1025. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1026. <p> </p>\
  1027. <p>P: +49 (0) 30 55 57 160-0</p>\
  1028. <p>F: +49 (0) 30 55 57 160-99</p>\
  1029. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1030. <p> </p>\
  1031. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1032. <p>Managing Director: Martin Edenhofer</p>\
  1033. <p> </p>\
  1034. <p>-----Original Message-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1035. <p> </p>\
  1036. <p>test email content</p>\
  1037. <p> </p>\
  1038. </div>'
  1039. should = '<div>\
  1040. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1041. <p> </p>\
  1042. <p><b>fett</b></p>\
  1043. <p> </p>\
  1044. <span class="js-signatureMarker"></span><p><span class=\"js-signatureMarker\"></span>--</p>\
  1045. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1046. <p> </p>\
  1047. <p>P: +49 (0) 30 55 57 160-0</p>\
  1048. <p>F: +49 (0) 30 55 57 160-99</p>\
  1049. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1050. <p> </p>\
  1051. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1052. <p>Managing Director: Martin Edenhofer</p>\
  1053. <p> </p>\
  1054. <p>-----Original Message-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1055. <p> </p>\
  1056. <p>test email content</p>\
  1057. <p> </p>\
  1058. </div>'
  1059. result = App.Utils.signatureIdentifyByHtml(message)
  1060. assert.equal(result, should)
  1061. // Office 365 (10325.20118) on Windows 10 Build 1803
  1062. // With German marker: -----Ursprüngliche Nachricht-----
  1063. // Without any existing <span class="js-signatureMarker"></span>
  1064. // Using fallback to signatureIdentifyByPlaintext
  1065. message = '<div>\
  1066. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1067. <p> </p>\
  1068. <p><b>fett</b></p>\
  1069. <p> </p>\
  1070. <p>--</p>\
  1071. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1072. <p> </p>\
  1073. <p>P: +49 (0) 30 55 57 160-0</p>\
  1074. <p>F: +49 (0) 30 55 57 160-99</p>\
  1075. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1076. <p> </p>\
  1077. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1078. <p>Managing Director: Martin Edenhofer</p>\
  1079. <p> </p>\
  1080. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1081. <p> </p>\
  1082. <p>test email content</p>\
  1083. <p> </p>\
  1084. </div>'
  1085. should = '<div>\
  1086. <p>Reply with Office 365 (10325.20118) on Windows 10 Build 1803</p>\
  1087. <p> </p>\
  1088. <p><b>fett</b></p>\
  1089. <p> </p>\
  1090. <p><span class=\"js-signatureMarker\"></span>--</p>\
  1091. <p>Zammad GmbH // Marienstraße 11 // 10117 Berlin // Germany</p>\
  1092. <p> </p>\
  1093. <p>P: +49 (0) 30 55 57 160-0</p>\
  1094. <p>F: +49 (0) 30 55 57 160-99</p>\
  1095. <p>W: <a href="https://zammad.com" rel="nofollow noreferrer noopener" target="_blank">https://zammad.com</a></p>\
  1096. <p> </p>\
  1097. <p>Location: Berlin - HRB 163946 B Amtsgericht Berlin-Charlottenburg</p>\
  1098. <p>Managing Director: Martin Edenhofer</p>\
  1099. <p> </p>\
  1100. <p>-----Ursprüngliche Nachricht-----<br>Von: Billy Zhou &lt;bz@zammad.com&gt; <br>Gesendet: Dienstag, 4. September 2018 15:33<br>An: me@zammad.com<br>Betreff: test email title</p>\
  1101. <p> </p>\
  1102. <p>test email content</p>\
  1103. <p> </p>\
  1104. </div>'
  1105. result = App.Utils.signatureIdentifyByHtml(message)
  1106. assert.equal(result, should)
  1107. });
  1108. // check attachment references
  1109. QUnit.test("check check attachment reference", assert => {
  1110. var message = 'some not existing'
  1111. var result = false
  1112. var verify = App.Utils.checkAttachmentReference(message)
  1113. assert.equal(verify, result)
  1114. message = 'some attachment for you'
  1115. result = 'attachment'
  1116. verify = App.Utils.checkAttachmentReference(message)
  1117. assert.equal(verify, result)
  1118. message = 'your attachment.'
  1119. result = 'attachment'
  1120. verify = App.Utils.checkAttachmentReference(message)
  1121. assert.equal(verify, result)
  1122. message = 'some otherattachment for you'
  1123. result = false
  1124. verify = App.Utils.checkAttachmentReference(message)
  1125. assert.equal(verify, result)
  1126. message = 'some attachmentother for you'
  1127. result = false
  1128. verify = App.Utils.checkAttachmentReference(message)
  1129. assert.equal(verify, result)
  1130. message = 'someattachment'
  1131. result = false
  1132. verify = App.Utils.checkAttachmentReference(message)
  1133. assert.equal(verify, result)
  1134. message = 'As enclosed you will find.'
  1135. result = 'enclosed'
  1136. verify = App.Utils.checkAttachmentReference(message)
  1137. assert.equal(verify, result)
  1138. 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>'
  1139. result = false
  1140. verify = App.Utils.checkAttachmentReference(message)
  1141. assert.equal(verify, result)
  1142. message = '<div>Hi Test,</div><div><blockquote type="cite">cite attachment </blockquote></div>'
  1143. result = false
  1144. verify = App.Utils.checkAttachmentReference(message)
  1145. assert.equal(verify, result)
  1146. message = '<div>Hi Test,</div><div><blockquote class="ecxgmail_quote">ecxgmail_quote attachment </blockquote></div>'
  1147. result = false
  1148. verify = App.Utils.checkAttachmentReference(message)
  1149. assert.equal(verify, result)
  1150. message = '<div>Hi Test,</div><div data-signature="true">ecxgmail_quote attachment</div>'
  1151. result = false
  1152. verify = App.Utils.checkAttachmentReference(message)
  1153. assert.equal(verify, result)
  1154. });
  1155. // replace tags
  1156. QUnit.test("check replace tags", assert => {
  1157. var formatNumber = function(num, digits) {
  1158. while (num.toString().length < digits) {
  1159. num = '0' + num
  1160. }
  1161. return num
  1162. }
  1163. var formatTimestamp = function(timestamp) {
  1164. localTime = new Date(Date.parse(timestamp))
  1165. d = formatNumber(localTime.getDate(), 2)
  1166. m = formatNumber(localTime.getMonth() + 1, 2)
  1167. yfull = localTime.getFullYear()
  1168. M = formatNumber(localTime.getMinutes(), 2)
  1169. H = formatNumber(localTime.getHours(), 2)
  1170. l = (H + 11) % 12 + 1
  1171. if (l < 10) {
  1172. l = ' ' + l
  1173. }
  1174. P = H >= 12 ? 'pm' : 'am'
  1175. return m + '/' + d + '/' + yfull + ' ' + l + ':' + M + ' ' + P
  1176. }
  1177. var message = "<div>#{user.firstname} #{user.lastname}</div>"
  1178. var result = '<div>Bob Smith</div>'
  1179. var data = {
  1180. user: {
  1181. firstname: 'Bob',
  1182. lastname: 'Smith',
  1183. },
  1184. }
  1185. var verify = App.Utils.replaceTags(message, data)
  1186. assert.equal(verify, result)
  1187. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1188. result = '<div>Bob Smith</div>'
  1189. data = {
  1190. user: {
  1191. firstname: function() { return 'Bob' },
  1192. lastname: function() { return 'Smith' },
  1193. },
  1194. }
  1195. verify = App.Utils.replaceTags(message, data)
  1196. assert.equal(verify, result)
  1197. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1198. result = '<div>Bob -</div>'
  1199. data = {
  1200. user: {
  1201. firstname: 'Bob',
  1202. },
  1203. }
  1204. verify = App.Utils.replaceTags(message, data)
  1205. assert.equal(verify, result)
  1206. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1207. result = '<div>Bob 0</div>'
  1208. data = {
  1209. user: {
  1210. firstname: 'Bob',
  1211. lastname: 0,
  1212. },
  1213. }
  1214. verify = App.Utils.replaceTags(message, data)
  1215. assert.equal(verify, result)
  1216. message = "<div>#{user.firstname} #{user.lastname}</div>"
  1217. result = '<div>Bob -</div>'
  1218. data = {
  1219. user: {
  1220. firstname: 'Bob',
  1221. lastname: '',
  1222. },
  1223. }
  1224. verify = App.Utils.replaceTags(message, data)
  1225. assert.equal(verify, result)
  1226. message = "<div>#{user.firstname} #{user.not.existing.test}</div>"
  1227. result = '<div>Bob -</div>'
  1228. data = {
  1229. user: {
  1230. firstname: 'Bob',
  1231. },
  1232. }
  1233. verify = App.Utils.replaceTags(message, data)
  1234. assert.equal(verify, result)
  1235. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1236. result = '<div>Bob -</div>'
  1237. data = {
  1238. user: {
  1239. firstname: 'Bob',
  1240. },
  1241. }
  1242. verify = App.Utils.replaceTags(message, data)
  1243. assert.equal(verify, result)
  1244. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1245. result = '<div>Bob -</div>'
  1246. data = {
  1247. user: {
  1248. firstname: 'Bob',
  1249. not: null,
  1250. },
  1251. }
  1252. verify = App.Utils.replaceTags(message, data)
  1253. assert.equal(verify, result)
  1254. message = "<div>#{user.firstname} #{not.existing.test}</div>"
  1255. result = '<div>Bob -</div>'
  1256. data = {
  1257. user: {
  1258. firstname: 'Bob',
  1259. not: {},
  1260. },
  1261. }
  1262. verify = App.Utils.replaceTags(message, data)
  1263. assert.equal(verify, result)
  1264. message = "<div>#{user.firstname} #{<a href=\"/test\">user.lastname</a>}</div>"
  1265. result = '<div>Bob Smith</div>'
  1266. data = {
  1267. user: {
  1268. firstname: 'Bob',
  1269. lastname: 'Smith',
  1270. },
  1271. }
  1272. verify = App.Utils.replaceTags(message, data)
  1273. assert.equal(verify, result)
  1274. message = "<div>issue #4973 #{user,firstname}</div>"
  1275. result = '<div>issue #4973 -</div>'
  1276. data = {
  1277. user: {
  1278. firstname: 'Bob',
  1279. lastname: 'Smith',
  1280. },
  1281. }
  1282. verify = App.Utils.replaceTags(message, data)
  1283. assert.equal(verify, result)
  1284. user = new App.User({
  1285. firstname: 'Bob',
  1286. lastname: 'Smith Good',
  1287. created_at: '2018-10-31T10:00:00Z',
  1288. })
  1289. message = "<div>#{user.firstname} #{user.created_at}</div>"
  1290. result = '<div>Bob ' + formatTimestamp('2018-10-31T10:00:00Z') + '</div>'
  1291. data = {
  1292. user: user
  1293. }
  1294. verify = App.Utils.replaceTags(message, data)
  1295. assert.equal(verify, result)
  1296. message = "<div>#{user.firstname} #{user.created_at.date}</div>"
  1297. result = '<div>Bob -</div>'
  1298. data = {
  1299. user: user
  1300. }
  1301. verify = App.Utils.replaceTags(message, data)
  1302. assert.equal(verify, result)
  1303. message = "<div>#{user.firstname} #{user.created.date}</div>"
  1304. result = '<div>Bob -</div>'
  1305. data = {
  1306. user: user
  1307. }
  1308. verify = App.Utils.replaceTags(message, data)
  1309. assert.equal(verify, result)
  1310. message = "<a href=\"https://example.co/q=#{user.lastname}\">some text</a>"
  1311. result = '<a href=\"https://example.co/q=Smith%20Good\">some text</a>'
  1312. data = {
  1313. user: user
  1314. }
  1315. verify = App.Utils.replaceTags(message, data, true)
  1316. assert.equal(verify, result)
  1317. var attribute_external_source = {
  1318. name: 'external_data_source', display: 'external_data_source', tag: 'autocompletion_ajax_external_data_source', null: true
  1319. };
  1320. App.Ticket.configure_attributes.push(attribute_external_source)
  1321. data = {
  1322. ticket: {
  1323. external_data_source: {
  1324. value: 1234,
  1325. label: 'Example Label'
  1326. }
  1327. }
  1328. }
  1329. message = "<a href=\"https://example.co/product/#{ticket.external_data_source}\">some text</a>"
  1330. result = '<a href=\"https://example.co/product/1234">some text</a>'
  1331. verify = App.Utils.replaceTags(message, data, true)
  1332. assert.equal(verify, result)
  1333. message = "<a href=\"https://example.co/product/#{ticket.external_data_source.value}\">some text</a>"
  1334. result = '<a href=\"https://example.co/product/Example%20Label">some text</a>'
  1335. verify = App.Utils.replaceTags(message, data, true)
  1336. assert.equal(verify, result)
  1337. data = { ticket: {} }
  1338. message = "Test: #{ticket.external_data_source}"
  1339. result = 'Test: -'
  1340. verify = App.Utils.replaceTags(message, data)
  1341. assert.equal(verify, result)
  1342. data = { ticket: {} }
  1343. message = "Test: #{ticket.external_data_source.value}"
  1344. result = 'Test: -'
  1345. verify = App.Utils.replaceTags(message, data)
  1346. assert.equal(verify, result)
  1347. var attribute_select = {
  1348. name: 'select', display: 'select', tag: 'select', null: true, nulloption: true, options: { a: 'Value A', b: 'Value B' }, value: null, historical_options: { a: 'Value A', b: 'Value B', c: 'Value C' }
  1349. }
  1350. App.Ticket.configure_attributes.push(attribute_select)
  1351. data = {
  1352. ticket: {
  1353. select: 'b',
  1354. }
  1355. }
  1356. message = "Test: #{ticket.select}"
  1357. result = 'Test: b'
  1358. verify = App.Utils.replaceTags(message, data)
  1359. assert.equal(verify, result)
  1360. message = "Test: #{ticket.select.value}"
  1361. result = 'Test: Value B'
  1362. verify = App.Utils.replaceTags(message, data)
  1363. assert.equal(verify, result)
  1364. data = { ticket: {} }
  1365. message = "Test: #{ticket.select}"
  1366. result = 'Test: -'
  1367. verify = App.Utils.replaceTags(message, data)
  1368. assert.equal(verify, result)
  1369. data = { ticket: {} }
  1370. message = "Test: #{ticket.select.value}"
  1371. result = 'Test: -'
  1372. verify = App.Utils.replaceTags(message, data)
  1373. assert.equal(verify, result)
  1374. var attribute_multiselect = {
  1375. name: 'multiselect', display: 'multiselect', tag: 'multiselect', null: true, nulloption: true, options: { a: 'Value A', b: 'Value B', c: 'Value C' }, value: null, historical_options: { a: 'Value A', b: 'Value B', c: 'Value C' }
  1376. }
  1377. App.Ticket.configure_attributes.push(attribute_multiselect)
  1378. data = {
  1379. ticket: {
  1380. multiselect: ['a', 'b'],
  1381. }
  1382. }
  1383. message = "Test: #{ticket.multiselect}"
  1384. result = 'Test: a, b'
  1385. verify = App.Utils.replaceTags(message, data)
  1386. assert.equal(verify, result)
  1387. message = "Test: #{ticket.multiselect.value}"
  1388. result = 'Test: Value A, Value B'
  1389. verify = App.Utils.replaceTags(message, data)
  1390. assert.equal(verify, result)
  1391. data = { ticket: {} }
  1392. message = "Test: #{ticket.multiselect}"
  1393. result = 'Test: -'
  1394. verify = App.Utils.replaceTags(message, data)
  1395. assert.equal(verify, result)
  1396. data = { ticket: {} }
  1397. message = "Test: #{ticket.multiselect.value}"
  1398. result = 'Test: -'
  1399. verify = App.Utils.replaceTags(message, data)
  1400. assert.equal(verify, result)
  1401. message = "<div>#{user.avatar(100, 100)}</div>"
  1402. result = '<div></div>'
  1403. data = {
  1404. user: user
  1405. }
  1406. verify = App.Utils.replaceTags(message, data)
  1407. assert.equal(verify, result)
  1408. user = new App.User({
  1409. firstname: 'Bob',
  1410. lastname: 'Smith Good',
  1411. created_at: '2018-10-31T10:00:00Z',
  1412. image: '808d0f10f81c8b1117608cb22a73076e'
  1413. })
  1414. message = "<div>#{user.avatar(100, 100)}</div>"
  1415. result = '<div><img src="api/v1/users/image/' + user.image + '" width="100" height="100" data-user-avatar="true" /></div>'
  1416. data = {
  1417. user: user
  1418. }
  1419. verify = App.Utils.replaceTags(message, data)
  1420. assert.equal(verify, result)
  1421. });
  1422. // check attibute validation
  1423. QUnit.test("check attibute validation", assert => {
  1424. var string = '123'
  1425. var result = '123'
  1426. var verify = App.Utils.htmlAttributeCleanup(string)
  1427. assert.equal(verify, result, string)
  1428. string = '123!'
  1429. result = '123'
  1430. verify = App.Utils.htmlAttributeCleanup(string)
  1431. assert.equal(verify, result, string)
  1432. string = '12 3!'
  1433. result = '123'
  1434. verify = App.Utils.htmlAttributeCleanup(string)
  1435. assert.equal(verify, result, string)
  1436. string = '12-3!'
  1437. result = '12-3'
  1438. verify = App.Utils.htmlAttributeCleanup(string)
  1439. assert.equal(verify, result, string)
  1440. string = '12_3!'
  1441. result = '12_3'
  1442. verify = App.Utils.htmlAttributeCleanup(string)
  1443. assert.equal(verify, result, string)
  1444. string = '^12_3!'
  1445. result = '12_3'
  1446. verify = App.Utils.htmlAttributeCleanup(string)
  1447. assert.equal(verify, result, string)
  1448. string = '^1\n 2_3!'
  1449. result = '12_3'
  1450. verify = App.Utils.htmlAttributeCleanup(string)
  1451. assert.equal(verify, result, string)
  1452. string = 'abc?'
  1453. result = 'abc'
  1454. verify = App.Utils.htmlAttributeCleanup(string)
  1455. assert.equal(verify, result, string)
  1456. string = 'abc."'
  1457. result = 'abc'
  1458. verify = App.Utils.htmlAttributeCleanup(string)
  1459. assert.equal(verify, result, string)
  1460. string = '#abc!^'
  1461. result = 'abc'
  1462. verify = App.Utils.htmlAttributeCleanup(string)
  1463. assert.equal(verify, result, string)
  1464. string = 'abc()=$'
  1465. result = 'abc'
  1466. verify = App.Utils.htmlAttributeCleanup(string)
  1467. assert.equal(verify, result, string)
  1468. string = "abc()=$\n123\rß"
  1469. result = 'abc123'
  1470. verify = App.Utils.htmlAttributeCleanup(string)
  1471. assert.equal(verify, result, string)
  1472. });
  1473. // check form diff
  1474. QUnit.test("check form diff", assert => {
  1475. var dataNow = {
  1476. owner_id: 1,
  1477. pending_date: '2015-01-28T09:39:00Z',
  1478. }
  1479. var dataLast = {
  1480. owner_id: '',
  1481. pending_date: '2015-01-28T09:39:00Z',
  1482. }
  1483. var diff = {}
  1484. var result = App.Utils.formDiff(dataNow, dataLast)
  1485. assert.deepEqual(result, diff, 'check form diff')
  1486. dataNow = {
  1487. owner_id: '1',
  1488. pending_date: '2015-01-28T09:39:00Z',
  1489. }
  1490. dataLast = {
  1491. owner_id: '',
  1492. pending_date: '2015-01-28T09:39:00Z',
  1493. }
  1494. diff = {}
  1495. result = App.Utils.formDiff(dataNow, dataLast)
  1496. assert.deepEqual(result, diff, 'check form diff')
  1497. dataNow = {
  1498. pending_date: '2015-01-28T09:39:00Z',
  1499. }
  1500. dataLast = {
  1501. owner_id: 1,
  1502. pending_date: '2015-01-28T09:39:00Z',
  1503. }
  1504. diff = {}
  1505. result = App.Utils.formDiff(dataNow, dataLast)
  1506. assert.deepEqual(result, diff, 'check form diff')
  1507. dataNow = {
  1508. owner_id: '',
  1509. pending_date: '2015-01-28T09:39:00Z',
  1510. }
  1511. dataLast = {
  1512. pending_date: '2015-01-28T09:39:00Z',
  1513. }
  1514. diff = {
  1515. }
  1516. result = App.Utils.formDiff(dataNow, dataLast)
  1517. assert.deepEqual(result, diff, 'check form diff')
  1518. dataNow = {
  1519. owner_id: '',
  1520. state_ids: [1,5,6,7],
  1521. }
  1522. dataLast = {}
  1523. diff = {
  1524. state_ids: ['1','5','6','7'],
  1525. }
  1526. result = App.Utils.formDiff(dataNow, dataLast)
  1527. assert.deepEqual(result, diff, 'check form diff')
  1528. dataNow = {
  1529. owner_id: 1,
  1530. state_ids: [1,5,7,6],
  1531. }
  1532. dataLast = {
  1533. owner_id: '',
  1534. state_ids: [1,5,6,7],
  1535. }
  1536. diff = {}
  1537. result = App.Utils.formDiff(dataNow, dataLast)
  1538. assert.deepEqual(result, diff, 'check form diff')
  1539. dataNow = {
  1540. owner_id: 1,
  1541. state_ids: [1,5,6,7],
  1542. }
  1543. dataLast = {
  1544. state_ids: ['1','5','7'],
  1545. }
  1546. diff = {
  1547. state_ids: ['6'],
  1548. }
  1549. result = App.Utils.formDiff(dataNow, dataLast)
  1550. assert.deepEqual(result, diff, 'check form diff')
  1551. dataNow = {
  1552. owner_id: '',
  1553. state_ids: [1,5,6,7],
  1554. }
  1555. dataLast = {
  1556. owner_id: 1,
  1557. state_ids: [1,5,6,7],
  1558. }
  1559. diff = {}
  1560. result = App.Utils.formDiff(dataNow, dataLast)
  1561. assert.deepEqual(result, diff, 'check form diff')
  1562. dataNow = {
  1563. owner_id: '',
  1564. state_ids: [1,5,6,7],
  1565. }
  1566. dataLast = {
  1567. owner_id: 5,
  1568. state_ids: [1,5,6,7],
  1569. }
  1570. diff = {
  1571. owner_id: ''
  1572. }
  1573. result = App.Utils.formDiff(dataNow, dataLast)
  1574. assert.deepEqual(result, diff, 'check form diff')
  1575. dataNow = {
  1576. state_id: 4,
  1577. pending_time: '2015-01-28T11:34:00Z'
  1578. }
  1579. dataLast = {
  1580. state_id: 5,
  1581. pending_time: undefined
  1582. }
  1583. diff = {
  1584. state_id: '4',
  1585. pending_time: '2015-01-28T11:34:00Z'
  1586. }
  1587. result = App.Utils.formDiff(dataNow, dataLast)
  1588. assert.deepEqual(result, diff, 'check form diff')
  1589. dataNow = {
  1590. pending_time: undefined
  1591. }
  1592. dataLast = {
  1593. pending_time: null
  1594. }
  1595. diff = {}
  1596. result = App.Utils.formDiff(dataNow, dataLast)
  1597. assert.deepEqual(result, diff, 'check form diff')
  1598. dataNow = {
  1599. ticket: {
  1600. pending_time: undefined,
  1601. },
  1602. }
  1603. dataLast = {
  1604. ticket: {
  1605. pending_time: null,
  1606. },
  1607. }
  1608. diff = {}
  1609. result = App.Utils.formDiff(dataNow, dataLast)
  1610. assert.deepEqual(result, diff, 'check form diff')
  1611. dataNow = {
  1612. test: '123',
  1613. ticket: {
  1614. pending_time: undefined,
  1615. },
  1616. }
  1617. dataLast = {
  1618. test: '123',
  1619. ticket: {
  1620. pending_time: null,
  1621. },
  1622. }
  1623. diff = {}
  1624. result = App.Utils.formDiff(dataNow, dataLast)
  1625. assert.deepEqual(result, diff, 'check form diff')
  1626. dataNow = {
  1627. test: '123',
  1628. }
  1629. dataLast = {}
  1630. diff = {
  1631. test: '123',
  1632. }
  1633. result = App.Utils.formDiff(dataNow, dataLast)
  1634. assert.deepEqual(result, diff, 'check form diff')
  1635. dataNow = {
  1636. test: '123',
  1637. }
  1638. dataLast = {
  1639. test: [1,2,3,4]
  1640. }
  1641. diff = {
  1642. test: '123',
  1643. }
  1644. result = App.Utils.formDiff(dataNow, dataLast)
  1645. assert.deepEqual(result, diff, 'check form diff')
  1646. dataNow = {
  1647. test: '123',
  1648. }
  1649. dataLast = {
  1650. test: {
  1651. 1: 1,
  1652. 2: 2,
  1653. }
  1654. }
  1655. diff = {
  1656. test: '123',
  1657. }
  1658. result = App.Utils.formDiff(dataNow, dataLast)
  1659. assert.deepEqual(result, diff, 'check form diff')
  1660. dataNow = {
  1661. test: [1,2,3,'4']
  1662. }
  1663. dataLast = {
  1664. test: '123',
  1665. }
  1666. diff = {
  1667. test: ['1','2','3','4']
  1668. }
  1669. result = App.Utils.formDiff(dataNow, dataLast)
  1670. assert.deepEqual(result, diff, 'check form diff')
  1671. dataNow = {
  1672. test: {
  1673. 1: 1,
  1674. 2: 2,
  1675. }
  1676. }
  1677. dataLast = {
  1678. test: '123',
  1679. }
  1680. diff = {
  1681. test: {
  1682. 1: '1',
  1683. 2: '2',
  1684. }
  1685. }
  1686. result = App.Utils.formDiff(dataNow, dataLast)
  1687. assert.deepEqual(result, diff, 'check form diff')
  1688. // regression test for issue #2042 - incorrect notification when closing a tab after setting up an object
  1689. // A newly created attribute will have the empty string as its value, this should be ignored for formDiff comparison
  1690. dataNow = {
  1691. test: '',
  1692. }
  1693. dataLast = {}
  1694. diff = {}
  1695. result = App.Utils.formDiff(dataNow, dataLast)
  1696. assert.deepEqual(result, diff, 'check form diff for a newly created attribute that is blank')
  1697. dataNow = {
  1698. test: '',
  1699. }
  1700. dataLast = {
  1701. test: '123',
  1702. }
  1703. diff = {
  1704. test: '',
  1705. }
  1706. result = App.Utils.formDiff(dataNow, dataLast)
  1707. assert.deepEqual(result, diff, 'check form diff for setting a previously valid value to blank')
  1708. dataNow = {
  1709. test: '123',
  1710. ticket: {
  1711. pending_time: undefined,
  1712. },
  1713. }
  1714. dataLast = {
  1715. ticket: {
  1716. pending_time: null,
  1717. },
  1718. }
  1719. diff = {
  1720. test: '123',
  1721. }
  1722. result = App.Utils.formDiff(dataNow, dataLast)
  1723. assert.deepEqual(result, diff, 'check form diff')
  1724. dataNow = undefined
  1725. dataLast = undefined
  1726. diff = {}
  1727. result = App.Utils.formDiff(dataNow, dataLast)
  1728. assert.deepEqual(result, diff, 'check form diff')
  1729. dataNow = {}
  1730. dataLast = {"number":"10012","title":"some subject 123äöü","group_id":1,"owner_id":1,"customer_id":2,"state_id":3,"priority_id":2,"article":{"from":"Test Admin Agent","to":"","cc":"","body":"dasdad","content_type":"text/html","ticket_id":12,"type_id":9,"sender_id":1,"internal":false,"form_id":"523405147"},"updated_at":"2015-01-29T09:22:23.000Z","pending_time":"2015-01-28T22:22:00.000Z","id":12}
  1731. diff = {}
  1732. result = App.Utils.formDiff(dataNow, dataLast)
  1733. assert.deepEqual(result, diff, 'check form diff')
  1734. // do not compare content of data instances/objects
  1735. no = function test_object() {
  1736. this.a = function() { return 123; }
  1737. this.b = function() { return '1234'; }
  1738. this.c = function() { return [123]; }
  1739. this.d = [1,2,3];
  1740. this.e = 'abc';
  1741. }
  1742. no1 = new no()
  1743. no2 = new no()
  1744. no3 = new no()
  1745. dataNow = {
  1746. number:'10013',
  1747. Article: [no1],
  1748. }
  1749. dataLast = {
  1750. number: "10012",
  1751. title: "some subject 123äöü",
  1752. Article: [ no2, no3 ],
  1753. }
  1754. diff = {
  1755. number:'10013',
  1756. }
  1757. result = App.Utils.formDiff(dataNow, dataLast)
  1758. assert.deepEqual(result, diff, 'check form diff')
  1759. dataNow = {
  1760. number:'10013',
  1761. Article: [no1,2],
  1762. }
  1763. dataLast = {
  1764. number: "10012",
  1765. title: "some subject 123äöü",
  1766. Article: [ no2, no3 ],
  1767. }
  1768. diff = {
  1769. number:'10013',
  1770. Article: ['2'],
  1771. }
  1772. result = App.Utils.formDiff(dataNow, dataLast)
  1773. assert.deepEqual(result, diff, 'check form diff')
  1774. dataNow = {
  1775. array: [1,2]
  1776. }
  1777. dataLast = {
  1778. array: [2, 3]
  1779. }
  1780. diff = {
  1781. array: ['1', '3']
  1782. }
  1783. result = App.Utils.formDiff(dataNow, dataLast)
  1784. assert.deepEqual(result, diff, 'check form diff in arrays both ways')
  1785. });
  1786. // check decimal format
  1787. QUnit.test("check decimal format", assert => {
  1788. var string = '123'
  1789. var result = '123.00'
  1790. var verify = App.Utils.decimal(string)
  1791. assert.equal(verify, result, string)
  1792. string = '0.6'
  1793. result = '0.60'
  1794. verify = App.Utils.decimal(string)
  1795. assert.equal(verify, result, string)
  1796. string = '6'
  1797. result = '6.00'
  1798. verify = App.Utils.decimal(string)
  1799. assert.equal(verify, result, string)
  1800. string = 6.5
  1801. result = '6.50'
  1802. verify = App.Utils.decimal(string)
  1803. assert.equal(verify, result, string)
  1804. string = '111111.6'
  1805. result = '111111.60'
  1806. verify = App.Utils.decimal(string)
  1807. assert.equal(verify, result, string)
  1808. string = '111111.622'
  1809. result = '111111.62'
  1810. verify = App.Utils.decimal(string)
  1811. assert.equal(verify, result, string)
  1812. string = 'abc.6'
  1813. result = 'abc.6'
  1814. verify = App.Utils.decimal(string)
  1815. assert.equal(verify, result, string)
  1816. string = ''
  1817. result = ''
  1818. verify = App.Utils.decimal(string)
  1819. assert.equal(verify, result, string)
  1820. string = undefined
  1821. result = ''
  1822. verify = App.Utils.decimal(string)
  1823. assert.equal(verify, result, string)
  1824. string = null
  1825. result = ''
  1826. verify = App.Utils.decimal(string)
  1827. assert.equal(verify, result, string)
  1828. });
  1829. // check formatTime format
  1830. QUnit.test("check formatTime format", assert => {
  1831. var string = '123'
  1832. var result = '123'
  1833. var verify = App.Utils.formatTime(string, 0)
  1834. assert.equal(verify, result, string)
  1835. string = '6'
  1836. result = '06'
  1837. verify = App.Utils.formatTime(string, 2)
  1838. assert.equal(verify, result, string)
  1839. string = ''
  1840. result = '00'
  1841. verify = App.Utils.formatTime(string, 2)
  1842. assert.equal(verify, result, string)
  1843. string = undefined
  1844. result = ''
  1845. verify = App.Utils.formatTime(string, 2)
  1846. assert.equal(verify, result, string)
  1847. string = null
  1848. result = ''
  1849. verify = App.Utils.formatTime(string, 2)
  1850. assert.equal(verify, result, string)
  1851. });
  1852. // check diffPosition
  1853. QUnit.test("check diffPosition format", assert => {
  1854. var a = [1,2,3,4]
  1855. var b = [1,2,3,4,5]
  1856. var result = [
  1857. {
  1858. position: 4,
  1859. id: 5,
  1860. },
  1861. ]
  1862. var verify = App.Utils.diffPositionAdd(a, b)
  1863. assert.deepEqual(verify, result)
  1864. a = [2,3,4]
  1865. b = [1,2,3,4]
  1866. result = [
  1867. {
  1868. position: 0,
  1869. id: 1,
  1870. },
  1871. ]
  1872. verify = App.Utils.diffPositionAdd(a, b)
  1873. assert.deepEqual(verify, result)
  1874. a = [2,3,4]
  1875. b = [1,2,3,4,5]
  1876. result = [
  1877. {
  1878. position: 0,
  1879. id: 1,
  1880. },
  1881. {
  1882. position: 4,
  1883. id: 5,
  1884. },
  1885. ]
  1886. verify = App.Utils.diffPositionAdd(a, b)
  1887. assert.deepEqual(verify, result)
  1888. a = [2,3,4]
  1889. b = [1,99,12,2,3,4,5]
  1890. result = [
  1891. {
  1892. position: 0,
  1893. id: 1,
  1894. },
  1895. {
  1896. position: 1,
  1897. id: 99,
  1898. },
  1899. {
  1900. position: 2,
  1901. id: 12,
  1902. },
  1903. {
  1904. position: 6,
  1905. id: 5,
  1906. },
  1907. ]
  1908. verify = App.Utils.diffPositionAdd(a, b)
  1909. assert.deepEqual(verify, result)
  1910. a = [4,3,1]
  1911. b = [1,2,3,4,5]
  1912. result = false
  1913. verify = App.Utils.diffPositionAdd(a, b)
  1914. assert.deepEqual(verify, result)
  1915. a = ['Ticket-347', 'TicketCreateScreen-2217']
  1916. b = ['Ticket-347', 'TicketCreateScreen-2217', 'TicketCreateScreen-71517']
  1917. result = [
  1918. {
  1919. position: 2,
  1920. id: 'TicketCreateScreen-71517',
  1921. },
  1922. ]
  1923. verify = App.Utils.diffPositionAdd(a, b)
  1924. assert.deepEqual(verify, result)
  1925. });
  1926. // check textLengthWithUrl format
  1927. QUnit.test("check textLengthWithUrl format", assert => {
  1928. var string = '123'
  1929. var result = 3
  1930. var verify = App.Utils.textLengthWithUrl(string)
  1931. assert.equal(verify, result)
  1932. string = '123 http is not here'
  1933. result = 20
  1934. verify = App.Utils.textLengthWithUrl(string)
  1935. assert.equal(verify, result)
  1936. string = '123 http://host is not here'
  1937. result = 39
  1938. verify = App.Utils.textLengthWithUrl(string)
  1939. assert.equal(verify, result)
  1940. string = '123 http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX is not here'
  1941. result = 39
  1942. verify = App.Utils.textLengthWithUrl(string)
  1943. assert.equal(verify, result)
  1944. string = 'http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
  1945. result = 23
  1946. verify = App.Utils.textLengthWithUrl(string)
  1947. assert.equal(verify, result)
  1948. string = 'http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, some other text'
  1949. result = 23 + 17
  1950. verify = App.Utils.textLengthWithUrl(string)
  1951. assert.equal(verify, result)
  1952. string = 'some other text,http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
  1953. result = 23 + 16
  1954. verify = App.Utils.textLengthWithUrl(string)
  1955. assert.equal(verify, result)
  1956. string = 'some other text, http://XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX?abc=123;aaa=ab+c usw'
  1957. result = 23 + 21
  1958. verify = App.Utils.textLengthWithUrl(string)
  1959. assert.equal(verify, result)
  1960. });
  1961. // check getRecipientArticle format
  1962. QUnit.test('check getRecipientArticle format', assert => {
  1963. var customer = {
  1964. login: 'login',
  1965. firstname: 'firstname',
  1966. lastname: 'lastname',
  1967. email: 'customer@example.com',
  1968. }
  1969. var ticket = {
  1970. customer: customer,
  1971. }
  1972. var article = {
  1973. type: {
  1974. name: 'phone',
  1975. },
  1976. sender: {
  1977. name: 'Customer',
  1978. },
  1979. from: customer.email,
  1980. to: 'some group',
  1981. message_id: 'message_id1',
  1982. created_by: {
  1983. login: 'login',
  1984. firstname: 'firstname',
  1985. lastname: 'lastname',
  1986. email: 'article_created_by@example.com',
  1987. },
  1988. }
  1989. var result = {
  1990. to: 'customer@example.com',
  1991. cc: '',
  1992. body: '',
  1993. in_reply_to: 'message_id1',
  1994. }
  1995. var verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  1996. assert.deepEqual(verify, result)
  1997. customer = {
  1998. login: 'login',
  1999. firstname: 'firstname',
  2000. lastname: 'lastname',
  2001. email: 'customer@example.com',
  2002. }
  2003. ticket = {
  2004. customer: customer,
  2005. }
  2006. article = {
  2007. type: {
  2008. name: 'phone',
  2009. },
  2010. sender: {
  2011. name: 'Customer',
  2012. },
  2013. from: customer.email,
  2014. message_id: 'message_id2',
  2015. created_by: {
  2016. login: 'login',
  2017. firstname: 'firstname',
  2018. lastname: 'lastname',
  2019. email: 'article_created_by@example.com',
  2020. },
  2021. }
  2022. result = {
  2023. to: customer.email,
  2024. cc: '',
  2025. body: '',
  2026. in_reply_to: 'message_id2',
  2027. }
  2028. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2029. assert.deepEqual(verify, result)
  2030. customer = {
  2031. login: 'login',
  2032. firstname: 'firstname',
  2033. lastname: 'lastname',
  2034. email: 'customer@example.com',
  2035. }
  2036. ticket = {
  2037. customer: customer,
  2038. }
  2039. article = {
  2040. message_id: 'message_id3',
  2041. type: {
  2042. name: 'phone',
  2043. },
  2044. sender: {
  2045. name: 'Agent',
  2046. },
  2047. from: 'article_created_by@example.com',
  2048. created_by: {
  2049. login: 'login',
  2050. firstname: 'firstname',
  2051. lastname: 'lastname',
  2052. email: 'article_created_by@example.com',
  2053. },
  2054. }
  2055. result = {
  2056. to: 'customer@example.com',
  2057. cc: '',
  2058. body: '',
  2059. in_reply_to: 'message_id3',
  2060. }
  2061. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2062. assert.deepEqual(verify, result)
  2063. customer = {
  2064. login: 'login',
  2065. firstname: 'firstname',
  2066. lastname: 'lastname',
  2067. email: 'customer@example.com',
  2068. }
  2069. ticket = {
  2070. customer: customer,
  2071. }
  2072. article = {
  2073. message_id: 'message_id4',
  2074. created_by: customer,
  2075. type: {
  2076. name: 'web',
  2077. },
  2078. sender: {
  2079. name: 'Customer',
  2080. },
  2081. from: customer.email,
  2082. to: 'some group',
  2083. created_by: {
  2084. login: 'login',
  2085. firstname: 'firstname',
  2086. lastname: 'lastname',
  2087. email: 'article_created_by@example.com',
  2088. },
  2089. }
  2090. result = {
  2091. to: 'customer@example.com',
  2092. cc: '',
  2093. body: '',
  2094. in_reply_to: 'message_id4',
  2095. }
  2096. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2097. assert.deepEqual(verify, result)
  2098. customer = {
  2099. login: 'login',
  2100. firstname: 'firstname',
  2101. lastname: 'lastname',
  2102. email: 'customer@example.com',
  2103. }
  2104. ticket = {
  2105. customer: customer,
  2106. }
  2107. article = {
  2108. message_id: 'message_id5',
  2109. type: {
  2110. name: 'web',
  2111. },
  2112. sender: {
  2113. name: 'Customer',
  2114. },
  2115. from: customer.email,
  2116. created_by: {
  2117. login: 'login',
  2118. firstname: 'firstname',
  2119. lastname: 'lastname',
  2120. email: 'article_created_by@example.com',
  2121. }
  2122. }
  2123. result = {
  2124. to: 'customer@example.com',
  2125. cc: '',
  2126. body: '',
  2127. in_reply_to: 'message_id5',
  2128. }
  2129. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2130. assert.deepEqual(verify, result)
  2131. customer = {
  2132. login: 'login',
  2133. firstname: 'firstname',
  2134. lastname: 'lastname',
  2135. email: 'customer@example.com',
  2136. }
  2137. ticket = {
  2138. customer: customer,
  2139. }
  2140. article = {
  2141. message_id: 'message_id6',
  2142. type: {
  2143. name: 'email',
  2144. },
  2145. sender: {
  2146. name: 'Customer',
  2147. },
  2148. from: customer.email,
  2149. to: 'some group',
  2150. created_by: {
  2151. login: 'login',
  2152. firstname: 'firstname',
  2153. lastname: 'lastname',
  2154. email: 'article_created_by@example.com',
  2155. }
  2156. }
  2157. result = {
  2158. to: 'customer@example.com',
  2159. cc: '',
  2160. body: '',
  2161. in_reply_to: 'message_id6',
  2162. }
  2163. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2164. assert.deepEqual(verify, result)
  2165. customer = {
  2166. login: 'login',
  2167. firstname: 'firstname',
  2168. lastname: 'lastname',
  2169. email: 'customer@example.com',
  2170. }
  2171. ticket = {
  2172. customer: customer,
  2173. }
  2174. article = {
  2175. message_id: 'message_id7',
  2176. type: {
  2177. name: 'email',
  2178. },
  2179. sender: {
  2180. name: 'Customer',
  2181. },
  2182. from: 'some other invalid part, ' + customer.email,
  2183. to: 'some group',
  2184. created_by: {
  2185. login: 'login',
  2186. firstname: 'firstname',
  2187. lastname: 'lastname',
  2188. email: 'article_created_by@example.com',
  2189. }
  2190. }
  2191. result = {
  2192. to: 'customer@example.com',
  2193. cc: '',
  2194. body: '',
  2195. in_reply_to: 'message_id7',
  2196. }
  2197. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2198. assert.deepEqual(verify, result)
  2199. customer = {
  2200. login: 'login',
  2201. firstname: 'firstname',
  2202. lastname: 'lastname',
  2203. email: 'customer@example.com',
  2204. }
  2205. ticket = {
  2206. customer: customer,
  2207. }
  2208. article = {
  2209. message_id: 'message_id7.1',
  2210. type: {
  2211. name: 'email',
  2212. },
  2213. sender: {
  2214. name: 'Customer',
  2215. },
  2216. from: 'some other invalid part, Some Realname ' + customer.email,
  2217. to: 'some group',
  2218. created_by: {
  2219. login: 'login',
  2220. firstname: 'firstname',
  2221. lastname: 'lastname',
  2222. email: 'article_created_by@example.com',
  2223. }
  2224. }
  2225. result = {
  2226. to: 'customer@example.com',
  2227. cc: '',
  2228. body: '',
  2229. in_reply_to: 'message_id7.1',
  2230. }
  2231. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2232. console.log(verify)
  2233. assert.deepEqual(verify, result)
  2234. customer = {
  2235. login: 'login',
  2236. firstname: 'firstname',
  2237. lastname: 'lastname',
  2238. email: 'customer@example.com',
  2239. }
  2240. ticket = {
  2241. customer: customer,
  2242. }
  2243. article = {
  2244. message_id: 'message_id7.2',
  2245. type: {
  2246. name: 'email',
  2247. },
  2248. sender: {
  2249. name: 'Customer',
  2250. },
  2251. from: 'some other invalid part, Some Realname ' + customer.email + ' , abc',
  2252. to: 'some group',
  2253. created_by: {
  2254. login: 'login',
  2255. firstname: 'firstname',
  2256. lastname: 'lastname',
  2257. email: 'article_created_by@example.com',
  2258. }
  2259. }
  2260. result = {
  2261. to: 'customer@example.com',
  2262. cc: '',
  2263. body: '',
  2264. in_reply_to: 'message_id7.2',
  2265. }
  2266. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2267. console.log(verify)
  2268. assert.deepEqual(verify, result)
  2269. customer = {
  2270. login: 'login',
  2271. firstname: 'firstname',
  2272. lastname: 'lastname',
  2273. email: 'customer@example.com',
  2274. }
  2275. agent = {
  2276. login: 'login',
  2277. firstname: 'firstname',
  2278. lastname: 'lastname',
  2279. email: 'agent@example.com',
  2280. }
  2281. ticket = {
  2282. customer: customer,
  2283. }
  2284. article = {
  2285. message_id: 'message_id8',
  2286. created_by: agent,
  2287. type: {
  2288. name: 'email',
  2289. },
  2290. sender: {
  2291. name: 'Agent',
  2292. },
  2293. from: 'customer2@example.com',
  2294. to: 'customer@example.com',
  2295. }
  2296. result = {
  2297. to: 'customer2@example.com',
  2298. cc: '',
  2299. body: '',
  2300. in_reply_to: 'message_id8',
  2301. }
  2302. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2303. assert.deepEqual(verify, result)
  2304. customer = {
  2305. login: 'login',
  2306. firstname: 'firstname',
  2307. lastname: 'lastname',
  2308. email: 'customer@example.com',
  2309. }
  2310. agent = {
  2311. login: 'login',
  2312. firstname: 'firstname',
  2313. lastname: 'lastname',
  2314. email: 'agent@example.com',
  2315. }
  2316. ticket = {
  2317. customer: customer,
  2318. }
  2319. article = {
  2320. message_id: 'message_id9',
  2321. created_by: agent,
  2322. type: {
  2323. name: 'email',
  2324. },
  2325. sender: {
  2326. name: 'Agent',
  2327. },
  2328. from: 'agent@example.com',
  2329. to: 'customer@example.com',
  2330. }
  2331. result = {
  2332. to: 'customer@example.com',
  2333. cc: '',
  2334. body: '',
  2335. in_reply_to: 'message_id9',
  2336. }
  2337. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2338. assert.deepEqual(verify, result)
  2339. customer = {
  2340. login: 'login',
  2341. firstname: 'firstname',
  2342. lastname: 'lastname',
  2343. email: 'customer@example.com',
  2344. }
  2345. agent = {
  2346. login: 'login',
  2347. firstname: 'firstname',
  2348. lastname: 'lastname',
  2349. email: 'agent@example.com',
  2350. }
  2351. ticket = {
  2352. customer: customer,
  2353. }
  2354. article = {
  2355. message_id: 'message_id10',
  2356. created_by: agent,
  2357. type: {
  2358. name: 'email',
  2359. },
  2360. sender: {
  2361. name: 'Agent',
  2362. },
  2363. from: 'Agent@Example.com',
  2364. to: 'customer@example.com',
  2365. cc: 'zammad@example.com',
  2366. }
  2367. result = {
  2368. to: 'customer@example.com',
  2369. cc: '',
  2370. body: '',
  2371. in_reply_to: 'message_id10',
  2372. }
  2373. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2374. assert.deepEqual(verify, result)
  2375. customer = {
  2376. login: 'login',
  2377. firstname: 'firstname',
  2378. lastname: 'lastname',
  2379. email: 'customer@example.com',
  2380. }
  2381. agent = {
  2382. login: 'login',
  2383. firstname: 'firstname',
  2384. lastname: 'lastname',
  2385. email: 'agent@example.com',
  2386. }
  2387. ticket = {
  2388. customer: customer,
  2389. }
  2390. article = {
  2391. message_id: 'message_id11',
  2392. created_by: agent,
  2393. type: {
  2394. name: 'email',
  2395. },
  2396. sender: {
  2397. name: 'Agent',
  2398. },
  2399. from: 'Agent@Example.com',
  2400. to: 'customer@example.com, agent@example.com',
  2401. cc: 'zammad@example.com',
  2402. }
  2403. result = {
  2404. to: 'customer@example.com, agent@example.com',
  2405. cc: 'zammad@example.com',
  2406. body: '',
  2407. in_reply_to: 'message_id11',
  2408. }
  2409. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type, [], true)
  2410. assert.deepEqual(verify, result)
  2411. customer = {
  2412. login: 'login',
  2413. firstname: 'firstname',
  2414. lastname: 'lastname',
  2415. email: 'customer@example.com',
  2416. }
  2417. agent = {
  2418. login: 'login',
  2419. firstname: 'firstname',
  2420. lastname: 'lastname',
  2421. email: 'agent@example.com',
  2422. }
  2423. ticket = {
  2424. customer: customer,
  2425. }
  2426. article = {
  2427. message_id: 'message_id12',
  2428. created_by: agent,
  2429. type: {
  2430. name: 'email',
  2431. },
  2432. sender: {
  2433. name: 'Agent',
  2434. },
  2435. from: 'Agent@Example.com',
  2436. to: 'customeR@EXAMPLE.com, agent@example.com',
  2437. cc: 'zammad@example.com, customer@example.com',
  2438. }
  2439. result = {
  2440. to: 'customer@example.com, agent@example.com',
  2441. cc: 'zammad@example.com',
  2442. body: '',
  2443. in_reply_to: 'message_id12',
  2444. }
  2445. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, [], true)
  2446. assert.deepEqual(verify, result)
  2447. customer = {
  2448. login: 'login',
  2449. firstname: 'firstname',
  2450. lastname: 'lastname',
  2451. email: 'customer@example.com',
  2452. }
  2453. agent = {
  2454. login: 'login',
  2455. firstname: 'firstname',
  2456. lastname: 'lastname',
  2457. email: 'agent@example.com',
  2458. }
  2459. ticket = {
  2460. customer: customer,
  2461. }
  2462. article = {
  2463. message_id: 'message_id13',
  2464. created_by: agent,
  2465. type: {
  2466. name: 'email',
  2467. },
  2468. sender: {
  2469. name: 'Agent',
  2470. },
  2471. from: 'Agent@Example.com',
  2472. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2473. cc: 'zammad@example.com, customer2@example.com',
  2474. }
  2475. result = {
  2476. to: 'customer@example.com, agent@example.com',
  2477. cc: 'customer2@example.com',
  2478. body: '',
  2479. in_reply_to: 'message_id13',
  2480. }
  2481. email_addresses = [
  2482. {
  2483. email: 'zammad@example.com',
  2484. },
  2485. {
  2486. email: 'zammad2@example.com',
  2487. }
  2488. ]
  2489. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2490. assert.deepEqual(verify, result)
  2491. customer = {
  2492. login: 'login',
  2493. firstname: 'firstname',
  2494. lastname: 'lastname',
  2495. email: 'customer@example.com',
  2496. }
  2497. agent = {
  2498. login: 'login',
  2499. firstname: 'firstname',
  2500. lastname: 'lastname',
  2501. email: 'AGENT@example.com',
  2502. }
  2503. ticket = {
  2504. customer: customer,
  2505. }
  2506. article = {
  2507. message_id: 'message_id14',
  2508. created_by: agent,
  2509. type: {
  2510. name: 'email',
  2511. },
  2512. sender: {
  2513. name: 'Agent',
  2514. },
  2515. from: 'Agent@Example.com',
  2516. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2517. cc: 'zammad@example.com, customer2@example.com',
  2518. }
  2519. result = {
  2520. to: 'customer@example.com, agent@example.com',
  2521. cc: 'customer2@example.com',
  2522. body: '',
  2523. in_reply_to: 'message_id14',
  2524. }
  2525. email_addresses = [
  2526. {
  2527. email: 'zammad@example.com',
  2528. },
  2529. {
  2530. email: 'zammad2@example.com',
  2531. }
  2532. ]
  2533. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2534. assert.deepEqual(verify, result)
  2535. customer = {
  2536. login: 'login',
  2537. firstname: 'firstname',
  2538. lastname: 'lastname',
  2539. email: 'zammad@example.com',
  2540. }
  2541. ticket = {
  2542. customer: customer,
  2543. }
  2544. article = {
  2545. message_id: 'message_id15',
  2546. created_by: customer,
  2547. type: {
  2548. name: 'email',
  2549. },
  2550. sender: {
  2551. name: 'Agent',
  2552. },
  2553. from: 'zammad@EXAMPLE.com',
  2554. to: 'customeR@EXAMPLE.com, agent@example.com, zammad2@EXAMPLE.com',
  2555. cc: 'zammad@example.com, customer2@example.com',
  2556. }
  2557. result = {
  2558. to: 'customer@example.com, agent@example.com',
  2559. cc: 'customer2@example.com',
  2560. body: '',
  2561. in_reply_to: 'message_id15',
  2562. }
  2563. email_addresses = [
  2564. {
  2565. email: 'zammad@example.com',
  2566. },
  2567. {
  2568. email: 'zammad2@example.com',
  2569. }
  2570. ]
  2571. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2572. assert.deepEqual(verify, result)
  2573. customer = {
  2574. login: 'login',
  2575. firstname: 'firstname',
  2576. lastname: 'lastname',
  2577. email: 'customer@example.com',
  2578. }
  2579. ticket = {
  2580. customer: customer,
  2581. }
  2582. article = {
  2583. message_id: 'message_id16',
  2584. created_by: customer,
  2585. type: {
  2586. name: 'email',
  2587. },
  2588. sender: {
  2589. name: 'Agent',
  2590. },
  2591. from: 'customer@example.com',
  2592. to: 'customer1@example.com, customer2@example.com, zammad@example.com',
  2593. cc: '',
  2594. }
  2595. result = {
  2596. to: 'customer1@example.com, customer2@example.com, customer@example.com',
  2597. cc: '',
  2598. body: '',
  2599. in_reply_to: 'message_id16',
  2600. }
  2601. email_addresses = [
  2602. {
  2603. email: 'zammad@example.com',
  2604. },
  2605. {
  2606. email: 'zammad2@example.com',
  2607. }
  2608. ]
  2609. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2610. assert.deepEqual(verify, result)
  2611. customer = {
  2612. login: 'login',
  2613. firstname: 'firstname',
  2614. lastname: 'lastname',
  2615. email: 'customer@example.com',
  2616. }
  2617. ticket = {
  2618. customer: customer,
  2619. }
  2620. article = {
  2621. message_id: 'message_id17',
  2622. created_by: customer,
  2623. type: {
  2624. name: 'email',
  2625. },
  2626. sender: {
  2627. name: 'Agent',
  2628. },
  2629. from: 'customer@example.com',
  2630. to: 'customer1@example.com, customer2@example.com, zammad@example.com, customer2+2@example.com',
  2631. cc: '',
  2632. }
  2633. result = {
  2634. to: 'customer1@example.com, customer2@example.com, customer2+2@example.com, customer@example.com',
  2635. cc: '',
  2636. body: '',
  2637. in_reply_to: 'message_id17',
  2638. }
  2639. email_addresses = [
  2640. {
  2641. email: 'zammad@example.com',
  2642. },
  2643. {
  2644. email: 'zammad2@example.com',
  2645. }
  2646. ]
  2647. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2648. assert.deepEqual(verify, result)
  2649. customer = {
  2650. login: 'login',
  2651. firstname: 'firstname',
  2652. lastname: 'lastname',
  2653. email: 'customer@example.com',
  2654. }
  2655. agent = {
  2656. login: 'login',
  2657. firstname: 'firstname',
  2658. lastname: 'lastname',
  2659. email: 'zammad@example.com',
  2660. }
  2661. ticket = {
  2662. customer: customer,
  2663. }
  2664. article = {
  2665. message_id: 'message_id18',
  2666. created_by: agent,
  2667. type: {
  2668. name: 'email',
  2669. },
  2670. sender: {
  2671. name: 'Agent',
  2672. },
  2673. from: 'zammad@example.com',
  2674. to: 'customer@example.com',
  2675. cc: '',
  2676. }
  2677. result = {
  2678. to: 'customer@example.com',
  2679. cc: '',
  2680. body: '',
  2681. in_reply_to: 'message_id18',
  2682. }
  2683. email_addresses = [
  2684. {
  2685. email: 'zammad@example.com',
  2686. },
  2687. {
  2688. email: 'zammad2@example.com',
  2689. }
  2690. ]
  2691. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, true)
  2692. assert.deepEqual(verify, result)
  2693. customer = {
  2694. login: 'login',
  2695. firstname: 'firstname',
  2696. lastname: 'lastname',
  2697. email: 'customer@example.com',
  2698. }
  2699. agent = {
  2700. login: 'login',
  2701. firstname: 'firstname',
  2702. lastname: 'lastname',
  2703. email: 'zammad@example.com',
  2704. }
  2705. ticket = {
  2706. customer: customer,
  2707. }
  2708. article = {
  2709. message_id: 'message_id19',
  2710. created_by: agent,
  2711. type: {
  2712. name: 'email',
  2713. },
  2714. sender: {
  2715. name: 'Agent',
  2716. },
  2717. from: 'Sender <zammad@example.com>',
  2718. to: 'Customer <customer@example.com>',
  2719. cc: '',
  2720. }
  2721. result = {
  2722. to: 'customer@example.com',
  2723. cc: '',
  2724. body: '',
  2725. in_reply_to: 'message_id19',
  2726. }
  2727. email_addresses = [
  2728. {
  2729. email: 'zammad@example.com',
  2730. },
  2731. {
  2732. email: 'zammad2@example.com',
  2733. }
  2734. ]
  2735. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2736. assert.deepEqual(verify, result)
  2737. agent = {
  2738. login: 'login',
  2739. firstname: 'firstname',
  2740. lastname: 'lastname',
  2741. email: 'agent@example.com',
  2742. }
  2743. ticket = {
  2744. customer: agent,
  2745. }
  2746. article = {
  2747. message_id: 'message_id20',
  2748. created_by: agent,
  2749. type: {
  2750. name: 'email',
  2751. },
  2752. sender: {
  2753. name: 'Agent',
  2754. },
  2755. from: 'Agent <Agent@Example.com>',
  2756. to: 'Sender <zammad@example.com>',
  2757. cc: '',
  2758. }
  2759. result = {
  2760. to: 'agent@example.com',
  2761. cc: '',
  2762. body: '',
  2763. in_reply_to: 'message_id20',
  2764. }
  2765. email_addresses = [
  2766. {
  2767. email: 'zammad@example.com',
  2768. },
  2769. {
  2770. email: 'zammad2@example.com',
  2771. }
  2772. ]
  2773. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2774. assert.deepEqual(verify, result)
  2775. agent = {
  2776. login: 'login',
  2777. firstname: 'firstname',
  2778. lastname: 'lastname',
  2779. email: 'agent@example.com',
  2780. }
  2781. ticket = {
  2782. customer: agent,
  2783. }
  2784. article = {
  2785. message_id: 'message_id20',
  2786. created_by: agent,
  2787. type: {
  2788. name: 'email',
  2789. },
  2790. sender: {
  2791. name: 'Agent',
  2792. },
  2793. from: 'Agent <Agent@Example.com>',
  2794. to: 'somebodyelse@example.com, Zammad <zammad@example.com>',
  2795. cc: '',
  2796. }
  2797. result = {
  2798. to: 'agent@example.com',
  2799. cc: '',
  2800. body: '',
  2801. in_reply_to: 'message_id20',
  2802. }
  2803. email_addresses = [
  2804. {
  2805. email: 'zammad@example.com',
  2806. },
  2807. {
  2808. email: 'zammad2@example.com',
  2809. }
  2810. ]
  2811. verify = App.Utils.getRecipientArticle(ticket, article, agent, article.type, email_addresses, false)
  2812. assert.deepEqual(verify, result)
  2813. customer = {
  2814. login: 'login',
  2815. firstname: 'firstname',
  2816. lastname: 'lastname',
  2817. email: "'customer@example.com'",
  2818. }
  2819. agent = {
  2820. login: 'login',
  2821. firstname: 'firstname',
  2822. lastname: 'lastname',
  2823. email: 'agent@example.com',
  2824. }
  2825. ticket = {
  2826. customer: customer,
  2827. }
  2828. article = {
  2829. message_id: 'message_id21',
  2830. created_by: agent,
  2831. type: {
  2832. name: 'email',
  2833. },
  2834. sender: {
  2835. name: 'Agent',
  2836. },
  2837. from: customer.email,
  2838. to: 'agent@example.com',
  2839. }
  2840. result = {
  2841. to: 'customer@example.com',
  2842. cc: '',
  2843. body: '',
  2844. in_reply_to: 'message_id21',
  2845. }
  2846. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2847. assert.deepEqual(verify, result)
  2848. // Regression test for issue #2184
  2849. // Case 1
  2850. // 1. Create a "Received Call" Ticket for article_customer
  2851. // 2. Change the Customer of the ticket to ticket_customer (but article.from still points to article_customer)
  2852. // 3. Reply to the first Article
  2853. // Recipient SHOULD BE Article.from
  2854. var article_customer = {
  2855. login: 'login',
  2856. firstname: 'article',
  2857. lastname: 'lastname',
  2858. email: 'article_customer@example.com',
  2859. }
  2860. var ticket_customer = {
  2861. login: 'login2',
  2862. firstname: 'ticket',
  2863. lastname: 'lastname',
  2864. email: 'ticket_customer@example.com',
  2865. }
  2866. ticket = {
  2867. customer: ticket_customer,
  2868. }
  2869. article = {
  2870. type: {
  2871. name: 'phone',
  2872. },
  2873. sender: {
  2874. name: 'Customer',
  2875. },
  2876. from: 'article lastname <article_customer@example.com>',
  2877. to: 'some group',
  2878. message_id: 'message_id22',
  2879. created_by: {
  2880. login: 'login',
  2881. firstname: 'firstname',
  2882. lastname: 'lastname',
  2883. email: 'article_created_by@example.com',
  2884. },
  2885. }
  2886. result = {
  2887. to: 'article_customer@example.com',
  2888. cc: '',
  2889. body: '',
  2890. in_reply_to: 'message_id22',
  2891. }
  2892. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2893. assert.deepEqual(verify, result)
  2894. // Regression test for issue #2184
  2895. // Case 2
  2896. // 1. Create a "Outbound Call" Ticket for article_customer
  2897. // 2. Change the Customer of the Ticket to ticket_customer (but article.to still points to article_customer)
  2898. // 3. Reply to the first Article
  2899. // Recipient SHOULD BE Article.to
  2900. article_customer = {
  2901. login: 'login',
  2902. firstname: 'article',
  2903. lastname: 'lastname',
  2904. email: 'article_customer@example.com',
  2905. }
  2906. ticket_customer = {
  2907. login: 'login2',
  2908. firstname: 'ticket',
  2909. lastname: 'lastname',
  2910. email: 'ticket_customer@example.com',
  2911. }
  2912. ticket = {
  2913. customer: ticket_customer,
  2914. }
  2915. article = {
  2916. type: {
  2917. name: 'phone',
  2918. },
  2919. sender: {
  2920. name: 'Agent',
  2921. },
  2922. from: 'agent1@example.com',
  2923. to: article_customer.email,
  2924. message_id: 'message_id23',
  2925. created_by: {
  2926. login: 'login',
  2927. firstname: 'firstname',
  2928. lastname: 'lastname',
  2929. email: 'article_created_by@example.com',
  2930. },
  2931. }
  2932. result = {
  2933. to: 'article_customer@example.com',
  2934. cc: '',
  2935. body: '',
  2936. in_reply_to: 'message_id23',
  2937. }
  2938. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type)
  2939. assert.deepEqual(verify, result)
  2940. // https://github.com/zammad/zammad/issues/2551
  2941. // If "From:" is local address and "Reply-To:" is available, use it
  2942. var article_customer = {
  2943. login: 'login',
  2944. firstname: 'article',
  2945. lastname: 'lastname',
  2946. email: 'article_customer@example.com',
  2947. }
  2948. var ticket_customer = {
  2949. login: 'login2',
  2950. firstname: 'ticket',
  2951. lastname: 'lastname',
  2952. email: 'ticket_customer@example.com',
  2953. }
  2954. ticket = {
  2955. customer: ticket_customer,
  2956. }
  2957. article = {
  2958. type: {
  2959. name: 'email',
  2960. },
  2961. sender: {
  2962. name: 'Customer',
  2963. },
  2964. from: 'article lastname <article_customer@example.com>',
  2965. to: 'some group',
  2966. reply_to: 'asd@example.com',
  2967. message_id: 'message_id22',
  2968. created_by: {
  2969. login: 'login',
  2970. firstname: 'firstname',
  2971. lastname: 'lastname',
  2972. email: 'article_created_by@example.com',
  2973. },
  2974. }
  2975. email_addresses = [{ email: 'article_customer@example.com'}]
  2976. result = {
  2977. to: 'asd@example.com',
  2978. cc: '',
  2979. body: '',
  2980. in_reply_to: 'message_id22',
  2981. }
  2982. verify = App.Utils.getRecipientArticle(ticket, article, article.created_by, article.type, email_addresses)
  2983. assert.deepEqual(verify, result)
  2984. });
  2985. QUnit.test("contentTypeCleanup", assert => {
  2986. var source = "image/png"
  2987. var should = "image/png"
  2988. var result = App.Utils.contentTypeCleanup(source)
  2989. assert.equal(result, should, source)
  2990. source = "image/png; some.file"
  2991. should = "image/png"
  2992. result = App.Utils.contentTypeCleanup(source)
  2993. assert.equal(result, should, source)
  2994. source = "image/png;some.file"
  2995. should = "image/png"
  2996. result = App.Utils.contentTypeCleanup(source)
  2997. assert.equal(result, should, source)
  2998. source = "image/jpeg;some.file"
  2999. should = "image/jpeg"
  3000. result = App.Utils.contentTypeCleanup(source)
  3001. assert.equal(result, should, source)
  3002. source = "image/jpg;some.file"
  3003. should = "image/jpg"
  3004. result = App.Utils.contentTypeCleanup(source)
  3005. assert.equal(result, should, source)
  3006. source = "image/gif;some.file"
  3007. should = "image/gif"
  3008. result = App.Utils.contentTypeCleanup(source)
  3009. assert.equal(result, should, source)
  3010. source = "image/gif\n;some.file"
  3011. should = "image/gif"
  3012. result = App.Utils.contentTypeCleanup(source)
  3013. assert.equal(result, should, source)
  3014. });
  3015. // htmlImage2DataUrl
  3016. QUnit.test("htmlImage2DataUrl", assert => {
  3017. var source = '<div>test 13</div>'
  3018. var should = '<div>test 13</div>'
  3019. var result = App.Utils.htmlImage2DataUrl(source)
  3020. assert.equal(result, should, source)
  3021. source = 'some test'
  3022. should = 'some test'
  3023. result = App.Utils.htmlImage2DataUrl(source)
  3024. assert.equal(result, should, source)
  3025. source = '<img src="some url">some test'
  3026. should = '<img src="data:,">some test'
  3027. result = App.Utils.htmlImage2DataUrl(source)
  3028. assert.equal(result, should, source)
  3029. source = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAADAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQQAQAAAAAAAAAAAAAAAAAAAAD/xAAUAQEAAAAAAAAAAAAAAAAAAAAF/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AbgQDv//Z">some test'
  3030. should = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAADAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACv/EABQQAQAAAAAAAAAAAAAAAAAAAAD/xAAUAQEAAAAAAAAAAAAAAAAAAAAF/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AbgQDv//Z">some test'
  3031. result = App.Utils.htmlImage2DataUrl(source)
  3032. assert.equal(result, should, source)
  3033. source = '<img src="data:image/jpeg;base64,some_data_123">some <img src="some url">test'
  3034. should = '<img src="data:image/jpeg;base64,some_data_123">some <img src="data:,">test'
  3035. result = App.Utils.htmlImage2DataUrl(source)
  3036. assert.equal(result, should, source)
  3037. // GitHub issue #2305
  3038. source = '<img src="cid:1234">some test'
  3039. should = '<img src="cid:1234">some test'
  3040. result = App.Utils.htmlImage2DataUrl(source)
  3041. assert.equal(result, should, source)
  3042. // GitHub issue #2701
  3043. source = '<img alt="foo">some test'
  3044. should = '<img alt="foo">some test'
  3045. result = App.Utils.htmlImage2DataUrl(source)
  3046. assert.equal(result, should, source)
  3047. });
  3048. QUnit.test('App.Utils.icon()', assert => {
  3049. // When given no arguments,
  3050. // expect @icon() to return null
  3051. assert.equal(App.Utils.icon(), null, 'with no arguments')
  3052. // On a modern browser and when given a single argument,
  3053. // expect @icon(name) to return an <svg> tag
  3054. window.svgPolyfill = false
  3055. svgTag = '<svg class="icon icon-foo "><use xlink:href="' + App.Config.get('icons_url') + '#icon-foo" /></svg>'
  3056. assert.equal(App.Utils.icon('foo'), svgTag, 'with one arg / no SVG polyfill')
  3057. // On a modern browser and when given two arguments,
  3058. // expect @icon(name) to return an <svg> tag
  3059. // with second arg as add'l class name
  3060. window.svgPolyfill = false
  3061. svgTag = '<svg class="icon icon-foo bar"><use xlink:href="' + App.Config.get('icons_url') + '#icon-foo" /></svg>'
  3062. assert.equal(App.Utils.icon('foo', 'bar'), svgTag, 'with two args / no SVG polyfill')
  3063. // On a browser requiring SVG polyfill and when given a single argument,
  3064. // expect @icon(name, class) to return an <svg> tag
  3065. // with pathless xlink:href attr
  3066. window.svgPolyfill = true
  3067. svgTag = '<svg class="icon icon-foo "><use xlink:href="#icon-foo" /></svg>'
  3068. assert.equal(App.Utils.icon('foo'), svgTag, 'with one arg / SVG polyfill')
  3069. // On a browser requiring SVG polyfill and when given two arguments,
  3070. // expect @icon(name, class) to return an <svg> tag
  3071. // with pathless xlink:href attr and second arg as add'l class name
  3072. window.svgPolyfill = true
  3073. svgTag = '<svg class="icon icon-foo bar"><use xlink:href="#icon-foo" /></svg>'
  3074. assert.equal(App.Utils.icon('foo', 'bar'), svgTag, 'with two args / SVG polyfill')
  3075. // For a left-to-right browser language and when given an argument containing '{start}' or '{end}',
  3076. // expect @icon(name) to return an <svg> tag
  3077. // replacing '{start}' with 'left' and '{end}' with 'right'
  3078. window.svgPolyfill = false
  3079. App.i18n.dir = function() { return 'ltr' }
  3080. svgTag = '<svg class="icon icon-arrow-left "><use xlink:href="' + App.Config.get('icons_url') + '#icon-arrow-left" /></svg>'
  3081. assert.equal(App.Utils.icon('arrow-{start}'), svgTag, 'for ltr locale / name includes "{start}"')
  3082. svgTag = '<svg class="icon icon-arrow-right "><use xlink:href="' + App.Config.get('icons_url') + '#icon-arrow-right" /></svg>'
  3083. assert.equal(App.Utils.icon('arrow-{end}'), svgTag, 'for ltr locale / name includes "{end}"')
  3084. // For a right-to-left browser language and when given an argument containing '{start}' or '{end}',
  3085. // expect @icon(name) to return an <svg> tag
  3086. // replacing '{start}' with 'left' and '{end}' with 'right'
  3087. window.svgPolyFill = false
  3088. App.i18n.dir = function() { return 'rtl' }
  3089. svgTag = '<svg class="icon icon-arrow-right "><use xlink:href="' + App.Config.get('icons_url') + '#icon-arrow-right" /></svg>'
  3090. assert.equal(App.Utils.icon('arrow-{start}'), svgTag, 'for rtl locale / name includes "{start}"')
  3091. svgTag = '<svg class="icon icon-arrow-left "><use xlink:href="' + App.Config.get('icons_url') + '#icon-arrow-left" /></svg>'
  3092. assert.equal(App.Utils.icon('arrow-{end}'), svgTag, 'for rtl locale / name includes "{end}"')
  3093. });
  3094. var source1 = '<img src="/assets/images/avatar-bg.png">some test'
  3095. $('#image2data1').html(source1)
  3096. var htmlImage2DataUrlTest1 = function() {
  3097. QUnit.test("htmlImage2DataUrl1 async", assert => {
  3098. var result1 = App.Utils.htmlImage2DataUrl(source1)
  3099. assert.ok(result1.match(/some test/), source1)
  3100. assert.ok(!result1.match(/avatar-bg.png/), source1)
  3101. assert.ok(result1.match(/^\<img src=\"data:image\/png;base64,/), source1)
  3102. });
  3103. }
  3104. $('#image2data1 img').one('load', htmlImage2DataUrlTest1)
  3105. var source2 = '<img src="/assets/images/chat-demo-avatar.png">some test'
  3106. $('#image2data2').html(source2)
  3107. var htmlImage2DataUrlTest2Success = function(element) {
  3108. QUnit.test('htmlImage2DataUrl2 async', assert => {
  3109. assert.ok(!$(element).html().match(/chat-demo-avatar/), source2)
  3110. assert.ok($(element).get(0).outerHTML.match(/^\<img src=\"data:image\/png;base64,/), source2)
  3111. assert.ok($(element).attr('style'), 'max-width: 100%;')
  3112. });
  3113. }
  3114. var htmlImage2DataUrlTest2Fail = function() {
  3115. QUnit.test('htmlImage2DataUrl2 async', assert => {
  3116. assert.ok(false, 'fail callback is exectuted!')
  3117. });
  3118. }
  3119. // Gitlab Issue #3538
  3120. // Jpeg images should convert to jpegs
  3121. // This functionality uses alt attribute present in img tag to get file type
  3122. // if alt attribute is missing then it will default to image/png
  3123. var jpegImageSource = '<img src="/assets/images/8000x300.jpg" alt="test.jpeg">jpeg image'
  3124. $('#jpegImage').html(jpegImageSource)
  3125. var htmlImage2DataUrlTest3 = function() {
  3126. QUnit.test("htmlImage2DataUrl3 async", assert => {
  3127. var result = App.Utils.htmlImage2DataUrl(jpegImageSource)
  3128. assert.ok(result.match(/jpeg image/), jpegImageSource)
  3129. assert.ok(result.match(/^\<img src=\"data:image\/jpeg;base64,/), jpegImageSource)
  3130. });
  3131. }
  3132. $('#jpegImage img').one('load', htmlImage2DataUrlTest3)
  3133. var pngImageSource = '<img src="/assets/images/1000x1000.png" alt="test.png">png image'
  3134. $('#pngImage').html(pngImageSource)
  3135. var htmlImage2DataUrlTest4 = function() {
  3136. QUnit.test("htmlImage2DataUrl4 async", assert => {
  3137. var result = App.Utils.htmlImage2DataUrl(pngImageSource)
  3138. assert.ok(result.match(/png image/), pngImageSource)
  3139. assert.ok(result.match(/^\<img src=\"data:image\/png;base64,/), pngImageSource)
  3140. });
  3141. }
  3142. $('#pngImage img').one('load', htmlImage2DataUrlTest4)
  3143. var jpegImageSourceWithoutAlt = '<img src="/assets/images/8000x300.jpg">jpeg image'
  3144. $('#jpegImage2').html(jpegImageSourceWithoutAlt)
  3145. var htmlImage2DataUrlTest5 = function() {
  3146. QUnit.test("htmlImage2DataUrl5 async", assert => {
  3147. var result = App.Utils.htmlImage2DataUrl(jpegImageSourceWithoutAlt)
  3148. assert.ok(result.match(/jpeg image/), jpegImageSourceWithoutAlt)
  3149. assert.ok(result.match(/^\<img src=\"data:image\/png;base64,/), jpegImageSourceWithoutAlt)
  3150. });
  3151. }
  3152. $('#jpegImage2 img').one('load', htmlImage2DataUrlTest5)
  3153. App.Utils.htmlImage2DataUrlAsyncInline($('#image2data2'), {success: htmlImage2DataUrlTest2Success, fail: htmlImage2DataUrlTest2Fail})
  3154. }
  3155. QUnit.test('App.Utils.baseUrl()', assert => {
  3156. configGetBackup = App.Config.get
  3157. // When FQDN is undefined or null,
  3158. // expect @baseUrl() to return window.location.origin
  3159. App.Config.get = function(key) { return undefined }
  3160. assert.equal(App.Utils.baseUrl(), window.location.origin, 'with undefined FQDN')
  3161. App.Config.get = function(key) { return null }
  3162. assert.equal(App.Utils.baseUrl(), window.location.origin, 'with null FQDN')
  3163. // When FQDN is zammad.example.com,
  3164. // expect @baseUrl() to return window.location.origin
  3165. App.Config.get = function(key) {
  3166. if (key === 'fqdn') {
  3167. return 'zammad.example.com'
  3168. }
  3169. }
  3170. assert.equal(App.Utils.baseUrl(), window.location.origin, 'with FQDN zammad.example.com')
  3171. // Otherwise,
  3172. // expect @baseUrl() to return FQDN with current HTTP(S) scheme
  3173. App.Config.get = function(key) {
  3174. if (key === 'fqdn') {
  3175. return 'foo.zammad.com'
  3176. } else if (key === 'http_type') {
  3177. return 'https'
  3178. }
  3179. }
  3180. assert.equal(App.Utils.baseUrl(), 'https://foo.zammad.com', 'with any other FQDN (and https scheme)')
  3181. App.Config.get = function(key) {
  3182. if (key === 'fqdn') {
  3183. return 'bar.zammad.com'
  3184. } else if (key === 'http_type') {
  3185. return 'http'
  3186. }
  3187. }
  3188. assert.equal(App.Utils.baseUrl(), 'http://bar.zammad.com', 'with any other FQDN (and http scheme)')
  3189. App.Config.get = configGetBackup
  3190. });
  3191. QUnit.test('App.Utils.joinUrlComponents()', assert => {
  3192. // When given a list of strings,
  3193. // expect @joinUrlComponents() to join them with slashes
  3194. assert.equal(App.Utils.joinUrlComponents('foo', 'bar', 'baz'), 'foo/bar/baz', 'with a destructured list of strings')
  3195. // When given an array of strings,
  3196. // expect @joinUrlComponents() to join them with slashes
  3197. assert.equal(App.Utils.joinUrlComponents(['foo', 'bar', 'baz']), 'foo/bar/baz', 'with an array of strings')
  3198. // When given a list of many types,
  3199. // expect @joinUrlComponents() to join their string representations with slashes
  3200. assert.equal(App.Utils.joinUrlComponents(0, 1, 'two', true, false, { foo: 'bar' }), '0/1/two/true/false/[object Object]', 'with a list of many types')
  3201. // When given a list including null or undefined,
  3202. // expect @joinUrlComponents() to filter them out of the results before joining the rest with slashes
  3203. assert.equal(App.Utils.joinUrlComponents('foo', undefined, 'bar', null, 'baz'), 'foo/bar/baz', 'with a list including null or undefined')
  3204. });
  3205. QUnit.test('App.Utils.clipboardHtmlIsWithText()', assert => {
  3206. // no content with text
  3207. assert.equal(App.Utils.clipboardHtmlIsWithText('<div></div>'), false)
  3208. assert.equal(App.Utils.clipboardHtmlIsWithText('<div> </div>'), false)
  3209. assert.equal(App.Utils.clipboardHtmlIsWithText('<div><img src="test.jpg"/></div>'), false)
  3210. assert.equal(App.Utils.clipboardHtmlIsWithText('<div><!-- some comment --></div>'), false)
  3211. assert.equal(App.Utils.clipboardHtmlIsWithText('<div><!-- some comment --> </div>'), false)
  3212. assert.equal(App.Utils.clipboardHtmlIsWithText("<div><!-- some comment --> \n </div>"), false)
  3213. // content with text
  3214. assert.equal(App.Utils.clipboardHtmlIsWithText('test'), true)
  3215. assert.equal(App.Utils.clipboardHtmlIsWithText('<div>test</div>'), true)
  3216. assert.equal(App.Utils.clipboardHtmlIsWithText('<meta http-equiv="content-type" content="text/html; charset=utf-8">sometext'), true)
  3217. });
  3218. QUnit.test('App.Utils.clipboardHtmlInsertPreperation()', assert => {
  3219. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div></div>', {}), '')
  3220. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div> </div>', {}), ' ')
  3221. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><img src="test.jpg"/></div>', {}), '<img src="test.jpg">')
  3222. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><!-- some comment --></div>', {}), '')
  3223. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><!-- some comment --> </div>', {}), ' ')
  3224. assert.equal(App.Utils.clipboardHtmlInsertPreperation("<div><!-- some comment --> \n </div>", {}), " \n ")
  3225. assert.equal(App.Utils.clipboardHtmlInsertPreperation('test', {}), 'test')
  3226. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div>test</div>', {}), 'test')
  3227. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<meta http-equiv="content-type" content="text/html; charset=utf-8">sometext', {}), '<span>sometext</span>')
  3228. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b> 123</div>', { mode: 'textonly' }), 'test 123')
  3229. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b><br> 123</div>', { mode: 'textonly' }), 'test 123')
  3230. assert.equal(App.Utils.clipboardHtmlInsertPreperation('<div><b>test</b><br> 123</div>', { mode: 'textonly', multiline: true }), 'test<br> 123')
  3231. });
  3232. QUnit.test('App.Utils.signatureIdentifyByHtmlHelper()', assert => {
  3233. result = App.Utils.signatureIdentifyByHtmlHelper("&lt;script&gt;alert('fish2');&lt;/script&gt;<blockquote></blockquote>")
  3234. assert.equal(result, "&lt;script&gt;alert('fish2');&lt;/script&gt;<span class=\"js-signatureMarker\"></span><blockquote></blockquote>", 'signatureIdentifyByHtmlHelper does not reactivate alert')
  3235. });
  3236. QUnit.test("#safeParseHtml", assert => {
  3237. var unwrap = input => $('<div>').html(input)[0].innerHTML
  3238. var html = "<div>test 123 </div>"
  3239. var result = App.Utils.safeParseHtml(html)
  3240. var should = html
  3241. assert.equal(unwrap(result), html)
  3242. // test if, according to jQuery, invalid HTML does not cause a a crash
  3243. // https://github.com/zammad/zammad/issues/3393
  3244. html = "<td></td><table></table><div>test 123 </div>"
  3245. should = "<table></table><div>test 123 </div>"
  3246. result = App.Utils.safeParseHtml(html)
  3247. assert.equal(unwrap(result), should)
  3248. })
  3249. QUnit.test("#buildEmailAddress", assert => {
  3250. assert.equal(
  3251. App.Utils.buildEmailAddress(undefined, 'undef@example.com'),
  3252. 'undef@example.com'
  3253. )
  3254. assert.equal(
  3255. App.Utils.buildEmailAddress(null, 'null@example.com'),
  3256. 'null@example.com'
  3257. )
  3258. assert.equal(
  3259. App.Utils.buildEmailAddress('', 'nobody@example.com'),
  3260. 'nobody@example.com'
  3261. )
  3262. assert.equal(
  3263. App.Utils.buildEmailAddress('John Doe', 'john.doe@example.com'),
  3264. 'John Doe <john.doe@example.com>'
  3265. )
  3266. assert.equal(
  3267. App.Utils.buildEmailAddress('Somebody @ "Company"', 'some.body@example.com'),
  3268. '"Somebody @ \\"Company\\"" <some.body@example.com>'
  3269. )
  3270. })