aaa_string_test.rb 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. # encoding: utf-8
  2. # rubocop:disable all
  3. require 'test_helper'
  4. class AaaStringTest < ActiveSupport::TestCase
  5. test 'to_filename ref' do
  6. modul = 'test'
  7. result = 'test'
  8. modul.to_filename
  9. assert_equal(result, modul)
  10. modul = 'Some::File'
  11. result = 'Some::File'
  12. modul.to_filename
  13. assert_equal(result, modul)
  14. end
  15. test 'to_filename function' do
  16. modul = 'test'
  17. result = 'test'
  18. assert_equal(result, modul.to_filename)
  19. modul = 'Some::File'
  20. result = 'some/file'
  21. assert_equal(result, modul.to_filename)
  22. end
  23. test 'to_classname ref' do
  24. modul = 'test'
  25. result = 'test'
  26. modul.to_filename
  27. assert_equal(result, modul)
  28. modul = 'some/file'
  29. result = 'some/file'
  30. modul.to_filename
  31. assert_equal(result, modul)
  32. end
  33. test 'to_classname function' do
  34. modul = 'test'
  35. result = 'Test'
  36. assert_equal(result, modul.to_classname)
  37. modul = 'some/file'
  38. result = 'Some::File'
  39. assert_equal(result, modul.to_classname)
  40. modul = 'some/files'
  41. result = 'Some::Files'
  42. assert_equal(result, modul.to_classname)
  43. modul = 'some_test/files'
  44. result = 'SomeTest::Files'
  45. assert_equal(result, modul.to_classname)
  46. end
  47. test 'html2text ref' do
  48. html = 'test'
  49. result = 'test'
  50. html.html2text
  51. assert_equal(result, html)
  52. html = '<div>test</div>'
  53. result = '<div>test</div>'
  54. html.html2text
  55. assert_equal(result, html)
  56. end
  57. test 'html2text function' do
  58. html = 'test'
  59. result = 'test'
  60. assert_equal(result, html.html2text)
  61. html = ' test '
  62. result = 'test'
  63. assert_equal(result, html.html2text)
  64. html = "\n\n test \n\n\n"
  65. result = 'test'
  66. assert_equal(result, html.html2text)
  67. html = '<div>test</div>'
  68. result = 'test'
  69. assert_equal(result, html.html2text)
  70. html = '<div>test<br></div>'
  71. result = 'test'
  72. assert_equal(result, html.html2text)
  73. html = "<div>test<br><br><br>\n<br>\n<br>\n</div>"
  74. result = 'test'
  75. assert_equal(result, html.html2text)
  76. html = "<div>test<br><br> <br> \n<br> \n<br> \n</div>"
  77. result = 'test'
  78. assert_equal(result, html.html2text)
  79. html = "<div>test<br><br>&nbsp;<br>&nbsp;\n<br>&nbsp;\n<br>&nbsp;\n</div>"
  80. result = 'test'
  81. assert_equal(result, html.html2text)
  82. html = "<div>test<br><br>&nbsp;<br>&nbsp;\n<br>&nbsp;\n<br>&nbsp;\n</div>&nbsp;"
  83. result = 'test'
  84. assert_equal(result, html.html2text)
  85. html = "<pre>test\n\ntest</pre>"
  86. result = "test\ntest"
  87. assert_equal(result, html.html2text)
  88. html = "<code>test\n\ntest</code>"
  89. result = "test\ntest"
  90. assert_equal(result, html.html2text)
  91. html = '<table><tr><td>test</td><td>col</td></td></tr><tr><td>test</td><td>4711</td></tr></table>'
  92. result = "test col\ntest 4711"
  93. assert_equal(result, html.html2text)
  94. html = "<p><span>Was\nsoll verbessert werden:</span></p>"
  95. result = 'Was soll verbessert werden:'
  96. assert_equal(result, html.html2text)
  97. html = "<!-- some comment -->
  98. <div>
  99. test<br><br><br>\n<br>\n<br>\n
  100. </div>"
  101. result = 'test'
  102. assert_equal(result, html.html2text)
  103. html = "\n<div><a href=\"https://zammad.org\">Best Tool of the World</a>
  104. some other text</div>
  105. <div>"
  106. result = "[1] Best Tool of the Worldsome other text\n\n[1] https://zammad.org"
  107. assert_equal(result, html.html2text)
  108. html = "<!-- some comment -->
  109. <div>
  110. test<br><br><br>\n<hr/>\n<br>\n
  111. </div>"
  112. result = "test\n\n___"
  113. assert_equal(result, html.html2text)
  114. html = "test<br><br><br>--<br>abc</div>"
  115. result = "test\n\n--\nabc"
  116. assert_equal(result, html.html2text)
  117. html = "Ihr RZ-Team<br />
  118. <br />
  119. <!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>test</o:Author> =
  120. <o:Template>A75DB76E.dotm</o:Template> <o:LastAuthor>test</o:LastAuthor> =
  121. <o:Revision>5</o:Revision> <o:Created>2011-05-18T07:08:00Z</o:Created> <=
  122. o:LastSaved>2011-07-04T17:59:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Wo=
  123. rds>189</o:Words> <o:Characters>1192</o:Characters> <o:Lines>9</o:Lines> =
  124. <o:Paragraphs>2</o:Paragraphs> <o:CharactersWithSpaces>1379</o:Characters=
  125. WithSpaces> <o:Version>11.5606</o:Version> </o:DocumentProperties></xml><!=
  126. [endif]-->"
  127. result = 'Ihr RZ-Team'
  128. assert_equal(result, html.html2text)
  129. html = '<html>
  130. <head>
  131. <title>Neues Fax von 1234-93900</title>
  132. </head>
  133. <body style="margin: 0px;padding: 0px;font-family: Arial, sans-serif;font-size: 12px;">
  134. <table cellpadding="0" cellspacing="0" width="100%" height="100%" bgcolor="#d9e7f0" id="mailbg" style="empty-cells:show;font-size: 12px;line-height: 18px;color: #000000;font-family: Arial, sans-serif;width: 100%;height: 100%;background-color: #d9e7f0;padding: 0px;margin: 0px;">
  135. <tr>
  136. <td valign="top">
  137. <center>
  138. <br><br>
  139. <table width="560" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" id="mailcontainer" style="empty-cells:show;font-size: 12px;line-height: 18px;color: #000000;font-family: Arial, sans-serif;width: 560px;margin: 0px auto;padding: 0px;background-color: #FFFFFF;">
  140. <tr>
  141. <td colspan="3" width="560" id="mail_header" valign="top" style="width: 560px;background-color: #FFFFFF;font-family: Arial, sans-serif;color: #000000;padding: 0px;margin: 0px;">
  142. <table width="560" cellpadding="0" cellspacing="0" style="empty-cells:show;font-size: 12px;line-height: 18px;color: #000000;font-family: Arial, sans-serif;">
  143. <tr>
  144. <td height="10" colspan="4" style="font-size:0px;line-height: 0px;padding:0px;height:10px;"><img src="http://www.example.docm/static/example.docm/mailtemplates/de_DE/team/img/tpl_header.gif" style="padding: 0px;margin: 0px;"></td>
  145. </tr>
  146. <tr>
  147. <td height="12" colspan="4"><span style="font-size:0px;line-height:0px;"> </span></td>
  148. </tr>
  149. <tr>
  150. <td height="27" width="30"> </td>
  151. <td height="27" width="397"><span class="mailtitle" style="font-family: Arial, sans-serif;color: #000000;font-size: 18px;line-height: 18px;font-weight: normal;">Neues Fax</span></td>
  152. <td height="27" width="103"><img src="http://www.example.docm/static/example.docm/mailtemplates/de_DE/team/img/tpl_logo-example.gif" style="padding: 0px;margin: 0px;"></td>
  153. <td height="27" width="30"></td>
  154. </tr>
  155. <tr>
  156. <td height="20" colspan="4"><span style="font-size:0px;line-height:0px;"> </span></td>
  157. </tr>
  158. <tr>
  159. <td height="1" colspan="4" style="font-size:0px;line-height: 0px;padding:0px;"><img src="http://www.example.docm/static/example.docm/mailtemplates/de_DE/team/img/tpl_line-grey.gif" style="padding: 0px;margin: 0px;"></td>
  160. </tr>
  161. </table>
  162. </td>
  163. </tr>
  164. <tr>
  165. <td colspan="3" width="560"> </td>
  166. </tr>
  167. <tr>
  168. <td width="30"> </td>
  169. <td width="500" height="30" valign="middle" align="right"><span class="accountno" style="font-family: Arial, sans-serif;font-size: 10px;color: #666666;">Ihre Kundennummer: 12345678</span></td>
  170. <td width="30"> </td>
  171. </tr>'
  172. result = 'Neues Fax von 1234-93900
  173. Neues Fax
  174. Ihre Kundennummer: 12345678'
  175. assert_equal(result, html.html2text)
  176. html = ' line&nbsp;1<br>
  177. you<br/>
  178. -----&amp;'
  179. should = 'line 1
  180. you
  181. -----&'
  182. assert_equal( should, html.html2text)
  183. html = ' <ul><li>#1</li><li>#2</li></ul>'
  184. should = '* #1
  185. * #2'
  186. assert_equal( should, html.html2text)
  187. html = '<!DOCTYPE html>
  188. <html>
  189. <head>
  190. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  191. <head>
  192. <body style="font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;">
  193. <div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div>
  194. </body>
  195. </html>'
  196. should = '> Welcome!
  197. >
  198. > Thank you for installing Zammad.
  199. >'
  200. assert_equal( should, html.html2text)
  201. html = ' <style type="text/css">
  202. body {
  203. width:90% !important;
  204. -webkit-text-size-adjust:90%;
  205. -ms-text-size-adjust:90%;
  206. font-family:\'helvetica neue\', helvetica, arial, geneva, sans-serif; f=
  207. ont-size: 12px;;
  208. }
  209. img {
  210. outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;
  211. }
  212. a img {
  213. border:none;
  214. }
  215. table td {
  216. border-collapse: collapse;
  217. }
  218. table {
  219. border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;
  220. }
  221. p, table, div, td {
  222. max-width: 600px;
  223. }
  224. p {
  225. margin: 0;
  226. }
  227. blockquote, pre {
  228. margin: 0px;
  229. padding: 8px 12px 8px 12px;
  230. }
  231. </style><p>some other content</p>'
  232. should = 'some other content'
  233. assert_equal( should, html.html2text)
  234. html = ' IT-Infrastruktur</span><br>
  235. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  236. <meta name="Generator" content="Microsoft Word 14 (filtered
  237. medium)">
  238. <!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
  239. o\:* {behavior:url(#default#VML);}
  240. w\:* {behavior:url(#default#VML);}
  241. .shape {behavior:url(#default#VML);}
  242. </style><![endif]-->
  243. <style><!--
  244. @font-face
  245. {font-family:calibri;
  246. panose-1:2 15 5 2 2 2 4 3 2 4;}
  247. @font-face
  248. {font-family:tahoma;
  249. panose-1:2 11 6 4 3 5 4 4 2 4;}
  250. p.msonormal, li.msonormal, div.msonormal
  251. {margin:0cm;
  252. margin-bottom:.0001pt;
  253. font-size:11.0pt;
  254. font-family:"calibri","sans-serif";
  255. mso-fareast-language:en-us;}
  256. a:link, span.msohyperlink
  257. {mso-style-priority:99;
  258. color:blue;
  259. text-decoration:underline;}
  260. a:visited, span.msohyperlinkfollowed
  261. {mso-style-priority:99;
  262. color:purple;
  263. text-decoration:underline;}
  264. p.msoacetate, li.msoacetate, div.msoacetate
  265. {mso-style-priority:99;
  266. mso-style-link:"sprechblasentext zchn";
  267. margin:0cm;
  268. margin-bottom:.0001pt;
  269. font-size:8.0pt;
  270. font-family:"tahoma","sans-serif";
  271. mso-fareast-language:en-us;}
  272. span.e-mailformatvorlage17
  273. {mso-style-type:personal;
  274. font-family:"calibri","sans-serif";
  275. color:windowtext;}
  276. span.sprechblasentextzchn
  277. {mso-style-name:"sprechblasentext zchn";
  278. mso-style-priority:99;
  279. mso-style-link:sprechblasentext;
  280. font-family:"tahoma","sans-serif";}
  281. .msochpdefault
  282. {mso-style-type:export-only;
  283. font-family:"calibri","sans-serif";
  284. mso-fareast-language:en-us;}
  285. @page wordsection1
  286. {size:612.0pt 792.0pt;
  287. margin:70.85pt 70.85pt 2.0cm 70.85pt;}
  288. div.wordsection1
  289. {page:wordsection1;}
  290. --></style><!--[if gte mso 9]><xml>
  291. <o:shapedefaults v:ext="edit" spidmax="1026" />
  292. </xml><![endif]--><!--[if gte mso 9]><xml>
  293. <o:shapelayout v:ext="edit">
  294. <o:idmap v:ext="edit" data="1" />
  295. </o:shapelayout></xml><![endif]-->'
  296. should = 'IT-Infrastruktur'
  297. assert_equal( should, html.html2text)
  298. html = "<h1>some head</h1>
  299. some content
  300. <blockquote>
  301. <p>line 1</p>
  302. <p>line 2</p>
  303. </blockquote>
  304. <p>some text later</p>"
  305. result = 'some head
  306. some content
  307. > line 1
  308. > line 2
  309. some text later'
  310. assert_equal(result, html.html2text)
  311. html = "<h1>some head</h1>
  312. some content
  313. <blockquote>
  314. line 1<br/>
  315. line 2<br>
  316. </blockquote>
  317. <p>some text later</p>"
  318. result = 'some head
  319. some content
  320. > line 1
  321. > line 2
  322. some text later'
  323. assert_equal(result, html.html2text)
  324. html = "<h1>some head</h1>
  325. some content
  326. <blockquote>
  327. <div><div>line 1</div><br></div>
  328. <div><div>line 2</div><br></div>
  329. </blockquote>
  330. some text later"
  331. result = 'some head
  332. some content
  333. > line 1
  334. >
  335. > line 2
  336. some text later'
  337. assert_equal(result, html.html2text)
  338. html = "<p>Best regards,</p>
  339. <p><i>Your Team Team</i></p>
  340. <p>P.S.: You receive this e-mail because you are listed in our database as person who ordered a Team license. Please click <a href=\"http://www.teamviewer.example/en/company/unsubscribe.aspx?id=1009645&ident=xxx\">here</a> to unsubscribe from further e-mails.</p>
  341. -----------------------------
  342. <br />"
  343. result = 'Best regards,
  344. Your Team Team
  345. P.S.: You receive this e-mail because you are listed in our database as person who ordered a Team license. Please click [1] here to unsubscribe from further e-mails.
  346. -----------------------------
  347. [1] http://www.teamviewer.example/en/company/unsubscribe.aspx?id=1009645&ident=xxx'
  348. assert_equal(result, html.html2text)
  349. html = "<div><br>Dave and leaned her
  350. days adam.</div><span style=\"color:#F7F3FF; font-size:8px\">Maybe we
  351. want any help me that.<br>Next morning charlie saw at their
  352. father.<br>Well as though adam took out here. Melvin will be more money.
  353. Called him into this one last thing.<br>Men-----------------------
  354. <br />"
  355. result = 'Dave and leaned her days adam.
  356. Maybe we want any help me that.
  357. Next morning charlie saw at their father.
  358. Well as though adam took out here. Melvin will be more money. Called him into this one last thing.
  359. Men-----------------------'
  360. assert_equal(result, html.html2text)
  361. end
  362. test 'html2html_strict function' do
  363. html = 'test'
  364. result = 'test'
  365. assert_equal(result, html.html2html_strict)
  366. html = ' test '
  367. result = 'test'
  368. assert_equal(result, html.html2html_strict)
  369. html = "\n\n test \n\n\n"
  370. result = 'test'
  371. assert_equal(result, html.html2html_strict)
  372. html = '<b>test</b>'
  373. result = '<b>test</b>'
  374. assert_equal(result, html.html2html_strict)
  375. html = '<B>test</B>'
  376. result = '<B>test</B>'
  377. assert_equal(result, html.html2html_strict)
  378. html = '<i>test</i>'
  379. result = '<i>test</i>'
  380. assert_equal(result, html.html2html_strict)
  381. html = '<h1>test</h1>'
  382. result = '<h1>test</h1>'
  383. assert_equal(result, html.html2html_strict)
  384. html = '<h2>test</h2>'
  385. result = '<h2>test</h2>'
  386. assert_equal(result, html.html2html_strict)
  387. html = '<h3>test</h3>'
  388. result = '<h3>test</h3>'
  389. assert_equal(result, html.html2html_strict)
  390. html = '<a href="http://example.com">http://example.com</a>'
  391. result = '<a href="http://example.com" target="_blank">http://example.com</a>'
  392. assert_equal(result, html.html2html_strict)
  393. html = '<A href="http://example.com?a=1;">http://example.com?a=1;</A>'
  394. result = '<a href="http://example.com?a=1;" target="_blank">http://example.com?a=1;</a>'
  395. assert_equal(result, html.html2html_strict)
  396. html = '<a href="http://web.de">web.de</a>'
  397. result = '<a href="http://web.de" target="_blank">web.de</a>'
  398. assert_equal(result, html.html2html_strict)
  399. html = '<a id="123" href="http://web.de">web.de</a>'
  400. result = '<a href="http://web.de" target="_blank">web.de</a>'
  401. assert_equal(result, html.html2html_strict)
  402. html = '<br>https://www.facebook.com/test<br>'
  403. result = '<a href="https://www.facebook.com/test" target="_blank">https://www.facebook.com/test</a>'
  404. assert_equal(result, html.html2html_strict)
  405. html = 'some text http://example.com some other text'
  406. result = 'some text <a href="http://example.com" target="_blank">http://example.com</a> some other text'
  407. assert_equal(result, html.html2html_strict)
  408. html = 'some text www.example.com some other text'
  409. result = 'some text <a href="http://www.example.com" target="_blank">http://www.example.com</a> some other text'
  410. assert_equal(result, html.html2html_strict)
  411. html = '<a href="http://example.com">http://what-different.example.com</a>'
  412. result = 'http://example.com (<a href="http://what-different.example.com" target="_blank">http://what-different.example.com</a>)'
  413. result = 'http://example.com (<a href="http://what-different.example.com" target="_blank">http://what-different.example.com</a>)'
  414. assert_equal(result, html.html2html_strict)
  415. html = '<a href="http://example.com">http://EXAMPLE.com</a>'
  416. result = '<a href="http://example.com" target="_blank">http://EXAMPLE.com</a>'
  417. assert_equal(result, html.html2html_strict)
  418. html = '<a href="http://example.com" class="abc">http://example.com</a>'
  419. result = '<a href="http://example.com" target="_blank">http://example.com</a>'
  420. assert_equal(result, html.html2html_strict)
  421. html = '<a href="http://example.com/" class="abc">http://example.com</a>'
  422. result = '<a href="http://example.com/" target="_blank">http://example.com</a>'
  423. assert_equal(result, html.html2html_strict)
  424. html = "<a href=\"http://example.com/\n\" class=\"abc\">http://example.com</a>"
  425. result = '<a href="http://example.com/" target="_blank">http://example.com</a>'
  426. assert_equal(result, html.html2html_strict)
  427. html = "<a href=\"http://example.com/\n \" class=\"abc\n\"\n>http://example.com</a>"
  428. result = '<a href="http://example.com/" target="_blank">http://example.com</a>'
  429. assert_equal(result, html.html2html_strict)
  430. html = "<div>http://example.com</div>"
  431. result = '<a href="http://example.com" target="_blank">http://example.com</a>'
  432. assert_equal(result, html.html2html_strict)
  433. html = "<div>http://example.com.</div>"
  434. result = '<a href="http://example.com" target="_blank">http://example.com</a>.'
  435. assert_equal(result, html.html2html_strict)
  436. html = "<div>http://example.com, and so on</div>"
  437. result = '<a href="http://example.com" target="_blank">http://example.com</a>, and so on'
  438. assert_equal(result, html.html2html_strict)
  439. html = "<div>http://example.com?lala=me, and so on</div>"
  440. result = '<a href="http://example.com?lala=me" target="_blank">http://example.com?lala=me</a>, and so on'
  441. assert_equal(result, html.html2html_strict)
  442. html = "<a href=\"http://facebook.de/examplesrbog\"><span lang=\"EN-US\" style='color:blue'>http://facebook.de/examplesrbog</span></a>"
  443. result = "<a href=\"http://facebook.de/examplesrbog\" target=\"_blank\">http://facebook.de/examplesrbog</a>"
  444. assert_equal(result, html.html2html_strict)
  445. html = "Damit Sie keinen Tag versäumen, empfehlen wir Ihnen den <a href=\"http://newsletters.cylex.de/\" class=\"\">Link des Adventkalenders</a> in<br class=\"\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ihrer Lesezeichen-Symbolleiste zu ergänzen.</p><div class=\"\">&nbsp;"
  446. result = "Damit Sie keinen Tag versäumen, empfehlen wir Ihnen den Link des Adventkalenders (<a href=\"http://newsletters.cylex.de/\" target=\"_blank\">http://newsletters.cylex.de/</a>) in<br>      Ihrer Lesezeichen-Symbolleiste zu ergänzen."
  447. assert_equal(result, html.html2html_strict)
  448. html = '<b >test</b>'
  449. result = '<b>test</b>'
  450. assert_equal(result, html.html2html_strict)
  451. html = '<b >test</b >'
  452. result = '<b>test</b>'
  453. assert_equal(result, html.html2html_strict)
  454. html = '<b >test< /b >'
  455. result = '<b>test</b>'
  456. assert_equal(result, html.html2html_strict)
  457. html = "<b\n>test<\n/b>"
  458. result = '<b>test</b>'
  459. assert_equal(result, html.html2html_strict)
  460. html = "<b id=123 classs=\"\nsome_class\">test</b>"
  461. result = '<b>test</b>'
  462. assert_equal(result, html.html2html_strict)
  463. html = "<b id=123 classs=\"\nsome_class\"\n>test<\n/b>"
  464. result = '<b>test</b>'
  465. assert_equal(result, html.html2html_strict)
  466. html = "<ul id=123 classs=\"\nsome_class\"\n><li>test</li>\n<li class=\"asasd\">test</li><\n/ul>"
  467. result = '<ul><li>test</li><li>test</li></ul>'
  468. assert_equal(result, html.html2html_strict)
  469. html = '<html><head><base href="x-msg://2849/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div lang="DE" link="blue" vlink="purple"><div class="Section1" style="page: Section1; "><div style="margin-top: 0cm; margin-right: 0cm; margin-left: 0cm; margin-bottom: 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span style="font-size: 10pt; font-family: Arial, sans-serif; ">Hallo Martin,<o:p></o:p></span></div>'
  470. result = 'Hallo Martin,'
  471. assert_equal(result, html.html2html_strict)
  472. html = '<a href="mailto:john.smith@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  473. result = 'john.smith@example.com'
  474. assert_equal(result, html.html2html_strict)
  475. html = '<a href="MAILTO:john.smith@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  476. result = 'john.smith@example.com'
  477. assert_equal(result, html.html2html_strict)
  478. html = '<a href="mailto:john.smith2@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  479. #result = 'john.smith@example.com (mailto:john.smith2@example.com)'
  480. result = 'john.smith@example.com'
  481. assert_equal(result, html.html2html_strict)
  482. end
  483. test 'signature_identify function' do
  484. marker_template = '######SIGNATURE_MARKER######'
  485. source = 'test'
  486. result = 'test'
  487. assert_equal(result, source.signature_identify(true))
  488. source = "test\n--\nend"
  489. result = "test\n#{marker_template}--\nend"
  490. assert_equal(result, source.signature_identify(true))
  491. source = "On 01/04/15 10:55, Bob Smith wrote:"
  492. result = "#{marker_template}On 01/04/15 10:55, Bob Smith wrote:"
  493. assert_equal(result, source.signature_identify(true))
  494. source = "Am 03.04.2015 um 20:58 schrieb Martin Edenhofer <me@znuny.ink>:"
  495. result = "#{marker_template}Am 03.04.2015 um 20:58 schrieb Martin Edenhofer <me@znuny.ink>:"
  496. assert_equal(result, source.signature_identify(true))
  497. source = "\ntest 123 \n1\n2\n3\n4\n5\n6\n7\n8\n9\n--\nBob Smith\n"
  498. result = "\ntest 123 \n1\n2\n3\n4\n5\n6\n7\n8\n9\n#{marker_template}--\nBob Smith\n"
  499. assert_equal(result, source.signature_identify(true))
  500. source = "test 123 \n--no not match--\n--\nBob Smith\n"
  501. result = "test 123 \n--no not match--\n#{marker_template}--\nBob Smith\n"
  502. assert_equal(result, source.signature_identify(true))
  503. source = "test 123 \n--no not match--\n -- \nBob Smith\n"
  504. result = "test 123 \n--no not match--\n#{marker_template} -- \nBob Smith\n"
  505. assert_equal(result, source.signature_identify(true))
  506. source = "test 123 \n\n--\nBob Smith\n\n\n\n\n--\nBob Smith\n"
  507. result = "test 123 \n#{marker_template}\n--\nBob Smith\n\n\n\n\n--\nBob Smith\n"
  508. assert_equal(result, source.signature_identify(true))
  509. source = "test 123\ntest 123\n--\nBob Smith\n"
  510. result = "test 123\ntest 123\n#{marker_template}--\nBob Smith\n"
  511. assert_equal(result, source.signature_identify(true))
  512. source = "test 123\ntest 123\n--\nBob Smith\n\n"
  513. result = "test 123\ntest 123\n#{marker_template}--\nBob Smith\n\n"
  514. assert_equal(result, source.signature_identify(true))
  515. # apple
  516. # en
  517. source = "test 123 \n--no not match--\nBob Smith\nOn 01/04/15 10:55, Bob Smith wrote:\nlalala\n--\nsome test"
  518. result = "test 123 \n--no not match--\nBob Smith\n#{marker_template}On 01/04/15 10:55, Bob Smith wrote:\nlalala\n#{marker_template}--\nsome test"
  519. assert_equal(result, source.signature_identify(true))
  520. # de
  521. source = "test 123 \n\n--no not match--\n\nBob Smith\nAm 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:\nlalala"
  522. result = "test 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}Am 03.04.2015 um 20:58 schrieb Bob Smith <bob@example.com>:\nlalala"
  523. assert_equal(result, source.signature_identify(true))
  524. # ms
  525. # en
  526. source = "test 123 \n\n--no not match--\n\nBob Smith\nFrom: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nSent: Donnerstag, 2. April 2015 10:00\nlalala</div>"
  527. result = "test 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}From: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nSent: Donnerstag, 2. April 2015 10:00\nlalala</div>"
  528. assert_equal(result, source.signature_identify(true))
  529. # de
  530. source = "test 123 \n\n--no not match--\n\nBob Smith\nVon: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 10:00\nBetreff: lalala\n"
  531. result = "test 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}Von: Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nGesendet: Donnerstag, 2. April 2015 10:00\nBetreff: lalala\n"
  532. assert_equal(result, source.signature_identify(true))
  533. # fr
  534. source = "\ntest 123 \n\n--no not match--\n\nBob Smith\nDe : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nEnvoyé : mercredi 29 avril 2015 17:31\nObjet : lalala\n"
  535. result = "\ntest 123 \n\n--no not match--\n\nBob Smith\n#{marker_template}De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]\nEnvoyé : mercredi 29 avril 2015 17:31\nObjet : lalala\n"
  536. assert_equal(result, source.signature_identify(true))
  537. marker_template = '<span class="js-signatureMarker"></span>'
  538. html = "<br>lalala<br>--<br>Max Mix"
  539. result = "lalala<br>#{marker_template}--<br>Max Mix"
  540. assert_equal(result, html.html2html_strict(true))
  541. html = "den.<br><br><b>Von:</b> Fritz Bauer [mailto:me@example.com]<br><b>Gesendet:</b> Donnerstag, 3. Mai 2012 11:51<br><b>An:</b> John Smith<br><b>Cc:</b> Smith, John Marian; johnel.fratczak@example.com; ole.brei@example.com; Günther John | Example GmbH; bkopon@example.com; john.heisterhagen@team.example.com; sven.rocked@example.com; michael.house@example.com; tgutzeit@example.com<br><b>Betreff:</b> Re: OTRS::XXX Erweiterung - Anhänge an CI's<br><br>Hallo,<br><br>ich versuche an den Punkten"
  542. result = "den.<br>#{marker_template}<br><b>Von:</b> Fritz Bauer [mailto:me@example.com]<br><b>Gesendet:</b> Donnerstag, 3. Mai 2012 11:51<br><b>An:</b> John Smith<br><b>Cc:</b> Smith, John Marian; johnel.fratczak@example.com; ole.brei@example.com; Günther John | Example GmbH; bkopon@example.com; john.heisterhagen@team.example.com; sven.rocked@example.com; michael.house@example.com; tgutzeit@example.com<br><b>Betreff:</b> Re: OTRS::XXX Erweiterung - Anhänge an CI&#39;s<br><br>Hallo,<br><br>ich versuche an den Punkten"
  543. assert_equal(result, html.html2html_strict(true))
  544. end
  545. end