aaa_string_test.rb 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. # rubocop:disable all
  2. require 'test_helper'
  3. class AaaStringTest < ActiveSupport::TestCase
  4. test 'strip' do
  5. raw = ' test '
  6. result = 'test'
  7. assert_equal(raw.strip, result)
  8. raw = "test\n"
  9. result = 'test'
  10. assert_equal(raw.strip, result)
  11. raw = " test \n test "
  12. result = "test \n test"
  13. assert_equal(raw.strip, result)
  14. raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}"
  15. result = "test \u{200B} \n test"
  16. assert_equal(raw.strip, result)
  17. raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT')
  18. result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT')
  19. assert_equal(raw.strip, result)
  20. end
  21. test 'strip!' do
  22. raw = ' test '
  23. result = 'test'
  24. raw.strip!
  25. assert_equal(raw, result)
  26. raw = "test\n"
  27. result = 'test'
  28. raw.strip!
  29. assert_equal(raw, result)
  30. raw = " test \n test "
  31. result = "test \n test"
  32. raw.strip!
  33. assert_equal(raw, result)
  34. raw = " \r\n test \u{200B} \n test\u{200B} \u{200B}"
  35. result = "test \u{200B} \n test"
  36. raw.strip!
  37. assert_equal(raw, result)
  38. raw = "\xC2\xA92011 Z ".force_encoding('ASCII-8BIT')
  39. result = "\xC2\xA92011 Z".force_encoding('ASCII-8BIT')
  40. raw.strip!
  41. assert_equal(raw, result)
  42. end
  43. test 'to_filename ref' do
  44. modul = 'test'
  45. result = 'test'
  46. modul.to_filename
  47. assert_equal(result, modul)
  48. modul = 'Some::File'
  49. result = 'Some::File'
  50. modul.to_filename
  51. assert_equal(result, modul)
  52. end
  53. test 'to_filename function' do
  54. modul = 'test'
  55. result = 'test'
  56. assert_equal(result, modul.to_filename)
  57. modul = 'Some::File'
  58. result = 'some/file'
  59. assert_equal(result, modul.to_filename)
  60. end
  61. test 'to_classname ref' do
  62. modul = 'test'
  63. result = 'test'
  64. modul.to_filename
  65. assert_equal(result, modul)
  66. modul = 'some/file'
  67. result = 'some/file'
  68. modul.to_filename
  69. assert_equal(result, modul)
  70. end
  71. test 'to_classname function' do
  72. modul = 'test'
  73. result = 'Test'
  74. assert_equal(result, modul.to_classname)
  75. modul = 'some/file'
  76. result = 'Some::File'
  77. assert_equal(result, modul.to_classname)
  78. modul = 'some/files'
  79. result = 'Some::Files'
  80. assert_equal(result, modul.to_classname)
  81. modul = 'some_test/files'
  82. result = 'SomeTest::Files'
  83. assert_equal(result, modul.to_classname)
  84. end
  85. test 'html2text ref' do
  86. html = 'test'
  87. result = 'test'
  88. html.html2text
  89. assert_equal(result, html)
  90. html = '<div>test</div>'
  91. result = '<div>test</div>'
  92. html.html2text
  93. assert_equal(result, html)
  94. end
  95. test 'html2text function' do
  96. html = 'test'
  97. result = 'test'
  98. assert_equal(result, html.html2text)
  99. html = ' test '
  100. result = 'test'
  101. assert_equal(result, html.html2text)
  102. html = "\n\n test \n\n\n"
  103. result = 'test'
  104. assert_equal(result, html.html2text)
  105. html = '<div>test</div>'
  106. result = 'test'
  107. assert_equal(result, html.html2text)
  108. html = '<div>test<br></div>'
  109. result = 'test'
  110. assert_equal(result, html.html2text)
  111. html = "<div>test<br><br><br>\n<br>\n<br>\n</div>"
  112. result = 'test'
  113. assert_equal(result, html.html2text)
  114. html = "<div>test<br><br> <br> \n<br> \n<br> \n</div>"
  115. result = 'test'
  116. assert_equal(result, html.html2text)
  117. html = "<div>test<br><br>&nbsp;<br>&nbsp;\n<br>&nbsp;\n<br>&nbsp;\n</div>"
  118. result = 'test'
  119. assert_equal(result, html.html2text)
  120. html = "<div>test<br><br>&nbsp;<br>&nbsp;\n<br>&nbsp;\n<br>&nbsp;\n</div>&nbsp;"
  121. result = 'test'
  122. assert_equal(result, html.html2text)
  123. html = "<pre>test\n\ntest</pre>"
  124. result = "test\ntest"
  125. assert_equal(result, html.html2text)
  126. html = "<code>test\n\ntest</code>"
  127. result = "test\ntest"
  128. assert_equal(result, html.html2text)
  129. html = '<table><tr><td>test</td><td>col</td></td></tr><tr><td>test</td><td>4711</td></tr></table>'
  130. result = "test col\ntest 4711"
  131. assert_equal(result, html.html2text)
  132. html = "<p><span>Was\nsoll verbessert werden:</span></p>"
  133. result = 'Was soll verbessert werden:'
  134. assert_equal(result, html.html2text)
  135. html = "<!-- some comment -->
  136. <div>
  137. test<br><br><br>\n<br>\n<br>\n
  138. </div>"
  139. result = 'test'
  140. assert_equal(result, html.html2text)
  141. html = "\n<div><a href=\"https://zammad.org\">Best Tool of the World</a>
  142. some other text</div>
  143. <div>"
  144. result = "[1] Best Tool of the Worldsome other text\n\n[1] https://zammad.org"
  145. assert_equal(result, html.html2text)
  146. html = "<!-- some comment -->
  147. <div>
  148. test<br><br><br>\n<hr/>\n<br>\n
  149. </div>"
  150. result = "test\n\n___"
  151. assert_equal(result, html.html2text)
  152. html = "test<br><br><br>--<br>abc</div>"
  153. result = "test\n\n--\nabc"
  154. assert_equal(result, html.html2text)
  155. html = "Ihr RZ-Team<br />
  156. <br />
  157. <!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>test</o:Author> =
  158. <o:Template>A75DB76E.dotm</o:Template> <o:LastAuthor>test</o:LastAuthor> =
  159. <o:Revision>5</o:Revision> <o:Created>2011-05-18T07:08:00Z</o:Created> <=
  160. o:LastSaved>2011-07-04T17:59:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Wo=
  161. rds>189</o:Words> <o:Characters>1192</o:Characters> <o:Lines>9</o:Lines> =
  162. <o:Paragraphs>2</o:Paragraphs> <o:CharactersWithSpaces>1379</o:Characters=
  163. WithSpaces> <o:Version>11.5606</o:Version> </o:DocumentProperties></xml><!=
  164. [endif]-->"
  165. result = 'Ihr RZ-Team'
  166. assert_equal(result, html.html2text)
  167. html = '<html>
  168. <head>
  169. <title>Neues Fax von 1234-93900</title>
  170. </head>
  171. <body style="margin: 0px;padding: 0px;font-family: Arial, sans-serif;font-size: 12px;">
  172. <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;">
  173. <tr>
  174. <td valign="top">
  175. <center>
  176. <br><br>
  177. <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;">
  178. <tr>
  179. <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;">
  180. <table width="560" cellpadding="0" cellspacing="0" style="empty-cells:show;font-size: 12px;line-height: 18px;color: #000000;font-family: Arial, sans-serif;">
  181. <tr>
  182. <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>
  183. </tr>
  184. <tr>
  185. <td height="12" colspan="4"><span style="font-size:0px;line-height:0px;"> </span></td>
  186. </tr>
  187. <tr>
  188. <td height="27" width="30"> </td>
  189. <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>
  190. <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>
  191. <td height="27" width="30"></td>
  192. </tr>
  193. <tr>
  194. <td height="20" colspan="4"><span style="font-size:0px;line-height:0px;"> </span></td>
  195. </tr>
  196. <tr>
  197. <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>
  198. </tr>
  199. </table>
  200. </td>
  201. </tr>
  202. <tr>
  203. <td colspan="3" width="560"> </td>
  204. </tr>
  205. <tr>
  206. <td width="30"> </td>
  207. <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>
  208. <td width="30"> </td>
  209. </tr>'
  210. result = 'Neues Fax von 1234-93900
  211. Neues Fax
  212. Ihre Kundennummer: 12345678'
  213. assert_equal(result, html.html2text)
  214. html = ' line&nbsp;1<br>
  215. you<br/>
  216. -----&amp;'
  217. should = 'line 1
  218. you
  219. -----&'
  220. assert_equal(should, html.html2text)
  221. html = ' <ul><li>#1</li><li>#2</li></ul>'
  222. should = '* #1
  223. * #2'
  224. assert_equal(should, html.html2text)
  225. html = '<!DOCTYPE html>
  226. <html>
  227. <head>
  228. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  229. <head>
  230. <body style="font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;">
  231. <div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad.</div><div>&gt;</div>
  232. </body>
  233. </html>'
  234. should = '> Welcome!
  235. >
  236. > Thank you for installing Zammad.
  237. >'
  238. assert_equal(should, html.html2text)
  239. html = ' <style type="text/css">
  240. body {
  241. width:90% !important;
  242. -webkit-text-size-adjust:90%;
  243. -ms-text-size-adjust:90%;
  244. font-family:\'helvetica neue\', helvetica, arial, geneva, sans-serif; f=
  245. ont-size: 12px;;
  246. }
  247. img {
  248. outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;
  249. }
  250. a img {
  251. border:none;
  252. }
  253. table td {
  254. border-collapse: collapse;
  255. }
  256. table {
  257. border-collapse: collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;
  258. }
  259. p, table, div, td {
  260. max-width: 600px;
  261. }
  262. p {
  263. margin: 0;
  264. }
  265. blockquote, pre {
  266. margin: 0px;
  267. padding: 8px 12px 8px 12px;
  268. }
  269. </style><p>some other content</p>'
  270. should = 'some other content'
  271. assert_equal(should, html.html2text)
  272. html = ' IT-Infrastruktur</span><br>
  273. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  274. <meta name="Generator" content="Microsoft Word 14 (filtered
  275. medium)">
  276. <!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
  277. o\:* {behavior:url(#default#VML);}
  278. w\:* {behavior:url(#default#VML);}
  279. .shape {behavior:url(#default#VML);}
  280. </style><![endif]-->
  281. <style><!--
  282. @font-face
  283. {font-family:calibri;
  284. panose-1:2 15 5 2 2 2 4 3 2 4;}
  285. @font-face
  286. {font-family:tahoma;
  287. panose-1:2 11 6 4 3 5 4 4 2 4;}
  288. p.msonormal, li.msonormal, div.msonormal
  289. {margin:0cm;
  290. margin-bottom:.0001pt;
  291. font-size:11.0pt;
  292. font-family:"calibri","sans-serif";
  293. mso-fareast-language:en-us;}
  294. a:link, span.msohyperlink
  295. {mso-style-priority:99;
  296. color:blue;
  297. text-decoration:underline;}
  298. a:visited, span.msohyperlinkfollowed
  299. {mso-style-priority:99;
  300. color:purple;
  301. text-decoration:underline;}
  302. p.msoacetate, li.msoacetate, div.msoacetate
  303. {mso-style-priority:99;
  304. mso-style-link:"sprechblasentext zchn";
  305. margin:0cm;
  306. margin-bottom:.0001pt;
  307. font-size:8.0pt;
  308. font-family:"tahoma","sans-serif";
  309. mso-fareast-language:en-us;}
  310. span.e-mailformatvorlage17
  311. {mso-style-type:personal;
  312. font-family:"calibri","sans-serif";
  313. color:windowtext;}
  314. span.sprechblasentextzchn
  315. {mso-style-name:"sprechblasentext zchn";
  316. mso-style-priority:99;
  317. mso-style-link:sprechblasentext;
  318. font-family:"tahoma","sans-serif";}
  319. .msochpdefault
  320. {mso-style-type:export-only;
  321. font-family:"calibri","sans-serif";
  322. mso-fareast-language:en-us;}
  323. @page wordsection1
  324. {size:612.0pt 792.0pt;
  325. margin:70.85pt 70.85pt 2.0cm 70.85pt;}
  326. div.wordsection1
  327. {page:wordsection1;}
  328. --></style><!--[if gte mso 9]><xml>
  329. <o:shapedefaults v:ext="edit" spidmax="1026" />
  330. </xml><![endif]--><!--[if gte mso 9]><xml>
  331. <o:shapelayout v:ext="edit">
  332. <o:idmap v:ext="edit" data="1" />
  333. </o:shapelayout></xml><![endif]-->'
  334. should = 'IT-Infrastruktur'
  335. assert_equal(should, html.html2text)
  336. html = "<h1>some head</h1>
  337. some content
  338. <blockquote>
  339. <p>line 1</p>
  340. <p>line 2</p>
  341. </blockquote>
  342. <p>some text later</p>"
  343. result = 'some head
  344. some content
  345. > line 1
  346. > line 2
  347. some text later'
  348. assert_equal(result, html.html2text)
  349. html = "<h1>some head</h1>
  350. some content
  351. <blockquote>
  352. line 1<br/>
  353. line 2<br>
  354. </blockquote>
  355. <p>some text later</p>"
  356. result = 'some head
  357. some content
  358. > line 1
  359. > line 2
  360. some text later'
  361. assert_equal(result, html.html2text)
  362. html = "<h1>some head</h1>
  363. some content
  364. <blockquote>
  365. <div><div>line 1</div><br></div>
  366. <div><div>line 2</div><br></div>
  367. </blockquote>
  368. some text later"
  369. result = 'some head
  370. some content
  371. > line 1
  372. >
  373. > line 2
  374. some text later'
  375. assert_equal(result, html.html2text)
  376. html = "<p>Best regards,</p>
  377. <p><i>Your Team Team</i></p>
  378. <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>
  379. -----------------------------
  380. <br />"
  381. result = 'Best regards,
  382. Your Team Team
  383. 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.
  384. -----------------------------
  385. [1] http://www.teamviewer.example/en/company/unsubscribe.aspx?id=1009645&ident=xxx'
  386. assert_equal(result, html.html2text)
  387. html = "<div><br>Dave and leaned her
  388. days adam.</div><span style=\"color:#F7F3FF; font-size:8px\">Maybe we
  389. want any help me that.<br>Next morning charlie saw at their
  390. father.<br>Well as though adam took out here. Melvin will be more money.
  391. Called him into this one last thing.<br>Men-----------------------
  392. <br />"
  393. result = 'Dave and leaned her days adam.
  394. Maybe we want any help me that.
  395. Next morning charlie saw at their father.
  396. Well as though adam took out here. Melvin will be more money. Called him into this one last thing.
  397. Men-----------------------'
  398. assert_equal(result, html.html2text)
  399. Timeout::timeout(2) do
  400. html = File.read(Rails.root.join('test', 'data', 'string', 'html2text1.html'))
  401. result = File.read(Rails.root.join('test', 'data', 'string', 'html2text1.txt'))
  402. assert_equal(result, html.html2text)
  403. end
  404. Timeout::timeout(2) do
  405. html = File.read(Rails.root.join('test', 'data', 'string', 'html2text2.html'))
  406. result = File.read(Rails.root.join('test', 'data', 'string', 'html2text2.txt'))
  407. assert_equal(result, html.html2text)
  408. end
  409. end
  410. test 'html2html_strict function' do
  411. html = 'test'
  412. result = 'test'
  413. assert_equal(result, html.html2html_strict)
  414. html = ' test '
  415. result = 'test'
  416. assert_equal(result, html.html2html_strict)
  417. html = "\n\n test \n\n\n"
  418. result = 'test'
  419. assert_equal(result, html.html2html_strict)
  420. html = '<b>test</b>'
  421. result = '<b>test</b>'
  422. assert_equal(result, html.html2html_strict)
  423. html = '<B>test</B>'
  424. result = '<b>test</b>'
  425. assert_equal(result, html.html2html_strict)
  426. html = '<i>test</i>'
  427. result = '<i>test</i>'
  428. assert_equal(result, html.html2html_strict)
  429. html = '<h1>test</h1>'
  430. result = '<h1>test</h1>'
  431. assert_equal(result, html.html2html_strict)
  432. html = '<h2>test</h2>'
  433. result = '<h2>test</h2>'
  434. assert_equal(result, html.html2html_strict)
  435. html = '<h3>test</h3>'
  436. result = '<h3>test</h3>'
  437. assert_equal(result, html.html2html_strict)
  438. html = '<h3>test</h3><!-- some comment -->'
  439. result = '<h3>test</h3>'
  440. assert_equal(result, html.html2html_strict)
  441. html = "<div>\n\n\ntest\n\n\n</div>"
  442. result = "<div>test</div>"
  443. assert_equal(result, html.html2html_strict)
  444. html = "<div>\n\t\ntest\n\t\n</div>"
  445. result = "<div>test</div>"
  446. assert_equal(result, html.html2html_strict)
  447. html = "<div>\n\t\ntest 123\n\t\n</div>"
  448. result = "<div>test 123</div>"
  449. assert_equal(result, html.html2html_strict)
  450. html = "<div> </div>"
  451. result = "<div> </div>"
  452. assert_equal(result, html.html2html_strict)
  453. html = "<div><br></div>"
  454. result = "<div>&nbsp;</div>"
  455. assert_equal(result, html.html2html_strict)
  456. html = "<div><p> </p><p> </p></div>"
  457. result = "<div>
  458. <p>&nbsp;</p></div>"
  459. assert_equal(result, html.html2html_strict)
  460. html = "<div><div> </div><div> </div></div>"
  461. result = "<div>&nbsp;</div>"
  462. assert_equal(result, html.html2html_strict)
  463. html = "<div><div> </div><div> </div><div> </div></div>"
  464. result = "<div>&nbsp;</div>"
  465. assert_equal(result, html.html2html_strict)
  466. html = "<div>
  467. <br> <br> </div>"
  468. result = "<div>&nbsp;</div>"
  469. assert_equal(result, html.html2html_strict)
  470. html = '<div>
  471. <br> <p><b>Description</b></p>
  472. <br> <br> </div>'
  473. result = '<div>
  474. <br> <p><b>Description</b></p><br> <br> </div>'
  475. assert_equal(result, html.html2html_strict)
  476. html = '<div>
  477. <br> <p><b>Description</b></p>
  478. <br> <br> <br> </div>'
  479. result = '<div>
  480. <br> <p><b>Description</b></p><br><br></div>'
  481. assert_equal(result, html.html2html_strict)
  482. html = '<p>&nbsp;</p><br><br><p>&nbsp;</p>'
  483. result = '<p>&nbsp;</p><p>&nbsp;</p>'
  484. assert_equal(result, html.html2html_strict)
  485. html = "<pre>a\nb\nc</pre>"
  486. result = "<pre>a\nb\nc</pre>"
  487. assert_equal(result, html.html2html_strict)
  488. html = "<div><pre>a\nb\nc</pre></div>"
  489. result = "<div><pre>a\nb\nc</pre></div>"
  490. assert_equal(result, html.html2html_strict)
  491. html = '<div class="WordSection1">
  492. <p class="MsoNormal"><span style="color:#1F497D">Guten Morgen, Frau Koppenhagen,<o:p></o:p></span></p>
  493. <p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
  494. <p class="MsoNormal"><span style="color:#1F497D">vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken?<o:p></o:p></span></p>
  495. <p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
  496. <p class="MsoNormal"><span style="color:#1F497D">Nochmals vielen Dank und herzliche Grüße
  497. <o:p></o:p></span></p>
  498. <div>'
  499. result = '<div>
  500. <p>Guten Morgen, Frau Koppenhagen,</p><p>&nbsp;</p><p>vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken?</p><p>&nbsp;</p><p>Nochmals vielen Dank und herzliche Grüße</p></div>'
  501. assert_equal(result, html.html2html_strict)
  502. html = '<a href="http://example.com">http://example.com</a>'
  503. result = '<a href="http://example.com" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>'
  504. assert_equal(result, html.html2html_strict)
  505. html = '<A href="http://example.com?a=1;">http://example.com?a=1;</A>'
  506. result = '<a href="http://example.com?a=1;" rel="nofollow noreferrer noopener" target="_blank">http://example.com?a=1;</a>'
  507. assert_equal(result, html.html2html_strict)
  508. html = '<A href="http://example.com/withSoMeUpper/And/downCase">http://example.com/withSoMeUpper/And/downCase</A>'
  509. result = '<a href="http://example.com/withSoMeUpper/And/downCase" rel="nofollow noreferrer noopener" target="_blank">http://example.com/withSoMeUpper/And/downCase</a>'
  510. assert_equal(result, html.html2html_strict)
  511. html = '<a href="http://web.de">web.de</a>'
  512. result = '<a href="http://web.de" rel="nofollow noreferrer noopener" target="_blank">web.de</a>'
  513. assert_equal(result, html.html2html_strict)
  514. html = '<a id="123" href="http://web.de">web.de</a>'
  515. result = '<a href="http://web.de" rel="nofollow noreferrer noopener" target="_blank">web.de</a>'
  516. assert_equal(result, html.html2html_strict)
  517. html = '<div>https://www.facebook.com/test</div>'
  518. result = '<div>
  519. <a href="https://www.facebook.com/test" rel="nofollow noreferrer noopener" target="_blank">https://www.facebook.com/test</a>
  520. </div>'
  521. assert_equal(result, html.html2html_strict)
  522. html = '<div><br>https://www.facebook.com/test<br></div>'
  523. result = '<div>
  524. <br><a href="https://www.facebook.com/test" rel="nofollow noreferrer noopener" target="_blank">https://www.facebook.com/test</a><br>
  525. </div>'
  526. assert_equal(result, html.html2html_strict)
  527. html = 'some text http://example.com some other text'
  528. result = 'some text <a href="http://example.com" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a> some other text'
  529. assert_equal(result, html.html2html_strict)
  530. html = 'some text www.example.com some other text'
  531. result = 'some text www.example.com some other text'
  532. assert_equal(result, html.html2html_strict)
  533. html = '<a href="http://example.com">http://what-different.example.com</a>'
  534. result = "<a href=\"http://example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\" title=\"http://example.com\">http://what-different.example.com</a>"
  535. assert_equal(result, html.html2html_strict)
  536. html = '<a href="http://example.com %22test%22">http://what-different.example.com</a>'
  537. result = "<a href=\"http://example.com%20%22test%22\" rel=\"nofollow noreferrer noopener\" target=\"_blank\" title='http://example.com \"test\"'>http://what-different.example.com</a>"
  538. assert_equal(result, html.html2html_strict)
  539. html = '<a href="http://example.com">http://EXAMPLE.com</a>'
  540. result = '<a href="http://example.com" rel="nofollow noreferrer noopener" target="_blank">http://EXAMPLE.com</a>'
  541. assert_equal(result, html.html2html_strict)
  542. html = '<a href="http://example.com" class="abc">http://example.com</a>'
  543. result = '<a href="http://example.com" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>'
  544. assert_equal(result, html.html2html_strict)
  545. html = '<a href="http://example.com/" class="abc">http://example.com</a>'
  546. result = '<a href="http://example.com/" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>'
  547. assert_equal(result, html.html2html_strict)
  548. html = "<a href=\"http://example.com/\n\" class=\"abc\">http://example.com</a>"
  549. result = '<a href="http://example.com/" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>'
  550. assert_equal(result, html.html2html_strict)
  551. html = "<a href=\"http://example.com/\n \" class=\"abc\n\"\n>http://example.com</a>"
  552. result = '<a href="http://example.com/" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>'
  553. assert_equal(result, html.html2html_strict)
  554. html = "<a href=\"http://example.com/?abc=123&123=abc\" class=\"abc\n\"\n>http://example.com?abc=123&amp;123=abc</a>"
  555. result = '<a href="http://example.com/?abc=123&amp;123=abc" rel="nofollow noreferrer noopener" target="_blank">http://example.com?abc=123&amp;123=abc</a>'
  556. assert_equal(result, html.html2html_strict)
  557. html = "<a href=\"http://example.com/?abc=123&123=abc\" class=\"abc\n\"\n>http://example.com?abc=123&amp;123=abc</a>"
  558. result = '<a href="http://example.com/?abc=123&amp;123=abc" rel="nofollow noreferrer noopener" target="_blank">http://example.com?abc=123&amp;123=abc</a>'
  559. assert_equal(result, html.html2html_strict)
  560. html = "<a href=\"http://example.com/?abc=123&123=abc\" class=\"abc\n\"\n><img src=\"cid:123\"></a>"
  561. result = '<a href="http://example.com/?abc=123&amp;123=abc" rel="nofollow noreferrer noopener" target="_blank" title="http://example.com/?abc=123&amp;123=abc"><img src="cid:123"></a>'
  562. assert_equal(result, html.html2html_strict)
  563. html = '<p><a href="https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;#ldap">https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;#ldap</a></p>'
  564. result = '<p><a href="https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;#ldap" rel="nofollow noreferrer noopener" target="_blank">https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;#ldap</a></p>'
  565. assert_equal(result, html.html2html_strict)
  566. html = '<p>https://wiki.lab.example.com/doku.php?id=xxxx:start&a=1;#ldap</p>'
  567. result = '<p><a href="https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;a=1;#ldap" rel="nofollow noreferrer noopener" target="_blank">https://wiki.lab.example.com/doku.php?id=xxxx:start&amp;a=1;#ldap</a></p>'
  568. assert_equal(result, html.html2html_strict)
  569. html = "<div>http://example.com</div>"
  570. result = "<div>\n<a href=\"http://example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">http://example.com</a>\n</div>"
  571. assert_equal(result, html.html2html_strict)
  572. html = "<div>http://example.com.</div>"
  573. result = "<div>\n<a href=\"http://example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">http://example.com</a>.</div>"
  574. assert_equal(result, html.html2html_strict)
  575. html = "<div>lala http://example.com.</div>"
  576. result = '<div>lala <a href="http://example.com" rel="nofollow noreferrer noopener" target="_blank">http://example.com</a>.</div>'
  577. assert_equal(result, html.html2html_strict)
  578. html = "<div>http://example.com, and so on</div>"
  579. result = "<div>\n<a href=\"http://example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">http://example.com</a>, and so on</div>"
  580. assert_equal(result, html.html2html_strict)
  581. html = "<div>http://example.com?lala=me, and so on</div>"
  582. result = "<div>\n<a href=\"http://example.com?lala=me\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">http://example.com?lala=me</a>, and so on</div>"
  583. assert_equal(result, html.html2html_strict)
  584. html = "<a href=\"http://facebook.de/examplesrbog\"><span lang=\"EN-US\" style='color:blue'>http://facebook.de/examplesrbog</span></a>"
  585. result = "<a href=\"http://facebook.de/examplesrbog\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">http://facebook.de/examplesrbog</a>"
  586. assert_equal(result, html.html2html_strict)
  587. html = "<span style=\"font-size:10.0pt;font-family:&quot;Cambria&quot;,serif;color:#1F497D;mso-fareast-language:DE\">web&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  588. <a href=\"http://www.example.com\"><span style=\"color:blue\">www.example.com</span></a><o:p></o:p></span>"
  589. result = "web <a href=\"http://www.example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">www.example.com</a>"
  590. assert_equal(result, html.html2html_strict)
  591. html = "web <a href=\"www.example.com\"><span style=\"color:blue\">www.example.com</span></a>"
  592. result = "web <a href=\"http://www.example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">www.example.com</a>"
  593. assert_equal(result, html.html2html_strict)
  594. 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;"
  595. result = "Damit Sie keinen Tag versäumen, empfehlen wir Ihnen den <a href=\"http://newsletters.cylex.de/\" rel=\"nofollow noreferrer noopener\" target=\"_blank\" title=\"http://newsletters.cylex.de/\">Link des Adventkalenders</a> in<br> Ihrer Lesezeichen-Symbolleiste zu ergänzen.<div> </div>"
  596. assert_equal(result, html.html2html_strict)
  597. html = '<a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#44546A">Hello Mr Smith,<o:p></o:p></span></a>'
  598. result = 'Hello Mr Smith,'
  599. assert_equal(result, html.html2html_strict)
  600. html = "<div>
  601. abc<p><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 </p></div>"
  602. result = "<div>abc<span class=\"js-signatureMarker\"></span><p><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 </p></div>"
  603. assert_equal(result, html.html2html_strict)
  604. html = "<div> abc<p> <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 </p></div>"
  605. result = "<div>abc<span class=\"js-signatureMarker\"></span><p> <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 </p></div>"
  606. assert_equal(result, html.html2html_strict)
  607. html = "<div> abc<p> <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 </p> </div>"
  608. result = "<div>abc<span class=\"js-signatureMarker\"></span><p> <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 </p></div>"
  609. assert_equal(result, html.html2html_strict)
  610. html = "<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; \">Mit freundlichem Gruß<span class=\"Apple-converted-space\">&nbsp;</span><br><br>John Smith<br>Service und Support<br><br>Example Service AG &amp; Co.<o:p></o:p></span></div><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; \">Management OHG<br>Someware-Str. 4<br>xxxxx Someware<br><br></span><span style=\"font-size: 10pt; font-family: Arial, sans-serif; \"><o:p></o:p></span></div><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; \">Tel.: +49 001 7601 462<br>Fax: +49 001 7601 472</span><span style=\"font-size: 10pt; font-family: Arial, sans-serif; \"><o:p></o:p></span></div><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; \"><a href=\"mailto:john.smith@example.com\" style=color: blue; text-decoration: underline; \">john.smith@example.com</a></span><span style=\"font-size: 10pt; font-family: Arial, sans-serif; \"><o:p></o:p></span></div><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; \"><a href=\"http://www.example.com\" style=\"color: blue; text-decoration: underline; \">www.example.com</a></span><span style=\"font-size: 10pt; font-family: Arial, sans-serif; \"><o:p></o:p></span></div>"
  611. result = "<div>Mit freundlichem Gruß<br><br>John Smith<br>Service und Support<br><br>Example Service AG &amp; Co. </div><div>Management OHG<br>Someware-Str. 4<br>xxxxx Someware<br><br>
  612. </div><div>Tel.: +49 001 7601 462<br>Fax: +49 001 7601 472 </div><div>john.smith@example.com</div><div>
  613. <a href=\"http://www.example.com\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">www.example.com</a>
  614. </div>"
  615. assert_equal(result, html.html2html_strict)
  616. html = '<b >test</b>'
  617. result = '<b>test</b>'
  618. assert_equal(result, html.html2html_strict)
  619. html = '<b >test</b >'
  620. result = '<b>test</b>'
  621. assert_equal(result, html.html2html_strict)
  622. html = '<b >test< /b >'
  623. result = '<b>test&lt; /b &gt;</b>'
  624. assert_equal(result, html.html2html_strict)
  625. html = "<b\n>test<\n/b>"
  626. result = "<b>test&lt; /b&gt;</b>"
  627. assert_equal(result, html.html2html_strict)
  628. html = '<table>
  629. <tr>
  630. <td bgcolor=white><font size=2 face="sans-serif"><b>Franz Schäfer</b></font>
  631. <tr>
  632. <td bgcolor=white><font size=2 face="sans-serif">Manager Information Systems</font></table>
  633. <br>
  634. <table>
  635. <tr>
  636. <td bgcolor=white><font size=2 face="sans-serif">Telefon &nbsp;</font>
  637. <td bgcolor=white><font size=2 face="sans-serif">+49 000 000 8565</font>
  638. <tr>
  639. <td colspan=2 bgcolor=white><font size=2 face="sans-serif">christian.schaefer@example.com</font></table>
  640. <br>
  641. <table>'
  642. result = "<b>Franz Schäfer</b><br><br><br><br>Telefon\n+49 000 000 8565<br>\nchristian.schaefer@example.com<br><br><br>"
  643. result = '<table>
  644. <tr>
  645. <td>
  646. <b>Franz Schäfer</b>
  647. </td>
  648. </tr>
  649. <tr>
  650. <td>Manager Information Systems</td>
  651. </tr>
  652. </table>
  653. <br>
  654. <table>
  655. <tr>
  656. <td> Telefon </td>
  657. <td> +49 000 000 8565 </td>
  658. </tr>
  659. <tr>
  660. <td colspan="2">christian.schaefer@example.com</td>
  661. </tr>
  662. </table>'
  663. assert_equal(result, html.html2html_strict)
  664. html = "<b id=123 classs=\"\nsome_class\">test</b>"
  665. result = '<b>test</b>'
  666. assert_equal(result, html.html2html_strict)
  667. html = "<b id=123 classs=\"\nsome_class\"\n>test<\n/b>"
  668. result = "<b>test&lt; /b&gt;</b>"
  669. assert_equal(result, html.html2html_strict)
  670. html = "<ul id=123 classs=\"\nsome_class\"\n><li>test</li>\n<li class=\"asasd\">test</li><\n/ul>"
  671. result = "<ul>\n<li>test</li>\n<li>test</li>&lt; /ul&gt;</ul>"
  672. assert_equal(result, html.html2html_strict)
  673. html = '<div><div>Hello Martin,</div></div>'
  674. result = '<div>Hello Martin,</div>'
  675. html.html2html_strict
  676. assert_equal(result, html.html2html_strict)
  677. html = '<div lang="DE"><div><div>Hello Martin,</div></div></div>'
  678. result = '<div>Hello Martin,</div>'
  679. assert_equal(result, html.html2html_strict)
  680. html = '<div lang="DE"><div><div>Hello Martin,</div> </div></div>'
  681. result = "<div>\n<div>Hello Martin,</div></div>"
  682. assert_equal(result, html.html2html_strict)
  683. html = '<span></span>'
  684. result = ''
  685. assert_equal(result, html.html2html_strict)
  686. html = '<div><s>abc</s></div>'
  687. result = '<div><s>abc</s></div>'
  688. assert_equal(result, html.html2html_strict)
  689. html = '<br><br><div>abc</div>'
  690. result = '<div>abc</div>'
  691. assert_equal(result, html.html2html_strict)
  692. html = '<div>abc</div><br> <br>'
  693. result = '<div>abc</div>'
  694. assert_equal(result, html.html2html_strict)
  695. html = '<div style="max-width: 600px;"><br><br><br></div>'
  696. result = '<div>&nbsp;</div>'
  697. assert_equal(result, html.html2html_strict)
  698. html = '<div style="max-width: 600px;"><br>abc<br><br></div>'
  699. result = '<div>
  700. <br>abc<br><br>
  701. </div>'
  702. assert_equal(result, html.html2html_strict)
  703. html = '<p> </p><p> </p><p> </p>'
  704. result = '<p>&nbsp;</p>'
  705. assert_equal(result, html.html2html_strict)
  706. html = '<div><p> </p>
  707. <p> </p>
  708. <p> </p>
  709. </div>'
  710. result = '<div>
  711. <p>&nbsp;</p></div>'
  712. assert_equal(result, html.html2html_strict)
  713. html = '<p lang="DE"><b><span></span></b></p>'
  714. result = '<p lang="DE"></p>'
  715. assert_equal(result, html.html2html_strict)
  716. html = '<div>lala<div lang="DE"><p><span>Hello Martin,</span></p></div></div>'
  717. result = "<div>lala<p>Hello Martin,</p></div>"
  718. html.html2html_strict
  719. assert_equal(result, html.html2html_strict)
  720. html = '<p lang="DE"><b><span>Hello Martin,</span></b></p>'
  721. result = '<p lang="DE"><b>Hello Martin,</b></p>'
  722. assert_equal(result, html.html2html_strict)
  723. html = '<body lang="DE" link="blue" vlink="purple"><div class="WordSection1">
  724. <p class="MsoNormal"><span style="color:#1F497D">Guten Morgen, Frau ABC,<o:p></o:p></span></p>
  725. <p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
  726. <p class="MsoNormal"><span style="color:#1F497D">vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken?<o:p></o:p></span></p>
  727. <p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
  728. <p class="MsoNormal"><span style="color:#1F497D">Nochmals vielen Dank und herzliche Grüße
  729. <o:p></o:p></span></p>
  730. <div>
  731. <p class="MsoNormal"><b><span style="font-size:10.0pt;color:#1F497D"><o:p>&nbsp;</o:p></span></b></p>
  732. <p class="MsoNormal"><b><span style="font-size:10.0pt;color:#1F497D">Anna Smith<o:p></o:p></span></b></p>
  733. <p class="MsoNormal"><b><span style="font-size:10.0pt;color:#1F497D">art abc SEV GmbH<o:p></o:p></span></b></p>
  734. <p class="MsoNormal"><b><span style="font-size:10.0pt;color:#1F497D">art abc TRAV<o:p></o:p></span></b></p>
  735. <p class="MsoNormal"><span style="font-size:9.0pt;color:#1F497D">Marktstätte 123<o:p></o:p></span></p>
  736. <p class="MsoNormal"><span style="font-size:9.0pt;color:#1F497D">123456 Dorten<o:p></o:p></span></p>
  737. <p class="MsoNormal"><span style="font-size:9.0pt;color:#1F497D">T: &#43;49 (0) 12345/1234560-1<o:p></o:p></span></p>
  738. <p class="MsoNormal"><span style="font-size:9.0pt;color:#1F497D">T: &#43;49 (0) 12345/1234560-0<o:p></o:p></span></p>
  739. <p class="MsoNormal"><span style="font-size:9.0pt;color:#1F497D">F: &#43;49 (0) 12345/1234560-2<o:p></o:p></span></p>
  740. <p class="MsoNormal"><a href="mailto:annad@example.com"><span style="font-size:9.0pt">annad@example.com</span></a><span style="font-size:9.0pt;color:#C00000"><o:p></o:p></span></p>
  741. <p class="MsoNormal"><a href="http://www.example.com/"><span style="font-size:9.0pt">www.example.com</span></a><span style="font-size:9.0pt;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  742. </span><a href="http://www.ABC.com/"><span style="font-size:9.0pt">www.ABC.com</span></a><span style="font-size:9.0pt;color:#1F497D"><o:p></o:p></span></p>
  743. <p class="MsoNormal"><span style="font-size:8.0pt;color:#1F497D">Geschäftsführer Vor Nach, VorUndZu Nach&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp; Amtsgericht Dort HRB 12345&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp; Ein Unternehmer der ABC Gruppe<o:p></o:p></span></p>'
  744. result = "<div>\n<p>Guten Morgen, Frau ABC,</p><p>&nbsp;</p><p>vielen Dank für die Reservierung. Dabei allerdings die Sprache (Niederländisch) nicht erwähnt. Können Sie bitte dieses in Ihrer Reservierung vormerken?</p><p>&nbsp;</p><p>Nochmals vielen Dank und herzliche Grüße</p><div> <p>&nbsp;</p><p><b>Anna Smith</b></p><p><b>art abc SEV GmbH</b></p><p><b>art abc TRAV</b></p><p>Marktstätte 123</p><p>123456 Dorten</p><p>T: +49 (0) 12345/1234560-1</p><p>T: +49 (0) 12345/1234560-0</p><p>F: +49 (0) 12345/1234560-2</p><p>annad@example.com</p><p><a href=\"http://www.example.com/\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">www.example.com</a> <a href=\"http://www.ABC.com/\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">www.ABC.com</a></p><p>Geschäftsführer Vor Nach, VorUndZu Nach - Amtsgericht Dort HRB 12345 - Ein Unternehmer der ABC Gruppe</p></div></div>"
  745. assert_equal(result, html.html2html_strict)
  746. html = '<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
  747. <div>
  748. <div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
  749. <p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">Von:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> Besucherbüro, MKuk [<a href="mailto:besucherbuero@example.com">mailto:besucherbuero@example.com</a>] <br>
  750. <b>Gesendet:</b> Freitag, 16. Dezember 2016 08:05<br>
  751. <b>An:</b> \'Amaia Epalza\'<br>
  752. <b>Betreff:</b> AW: Gruppe vtb Kultuur // 28.06.2017<o:p></o:p></span></p>
  753. </div>
  754. </div>
  755. <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
  756. <p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:#1F497D">Reservierungsbestätigung Führung Skulptur-Projekte 2017 am
  757. </span></b><o:p></o:p></p>
  758. <p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:#1F497D">&nbsp;</span><o:p></o:p></p>
  759. <p class="MsoNormal">Guten Morgen Frau Epalza,<o:p></o:p></p>'
  760. result = '<p>&nbsp;</p><div>
  761. <div>
  762. <span class="js-signatureMarker"></span><p><b>Von:</b> Besucherbüro, MKuk [besucherbuero@example.com] <br>
  763. <b>Gesendet:</b> Freitag, 16. Dezember 2016 08:05<br>
  764. <b>An:</b> \'Amaia Epalza\'<br>
  765. <b>Betreff:</b> AW: Gruppe vtb Kultuur // 28.06.2017</p></div></div><p>&nbsp;</p><p><b>Reservierungsbestätigung Führung Skulptur-Projekte 2017 am </b></p><p>&nbsp;</p><p>Guten Morgen Frau Epalza,</p>'
  766. assert_equal(result, html.html2html_strict)
  767. 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; ">Hello Martin,<o:p></o:p></span></div>'
  768. result = '<div>Hello Martin,</div>'
  769. assert_equal(result, html.html2html_strict)
  770. html = '<a href="mailto:john.smith@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  771. result = 'john.smith@example.com'
  772. assert_equal(result, html.html2html_strict)
  773. html = '<a href="MAILTO:john.smith@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  774. result = 'john.smith@example.com'
  775. assert_equal(result, html.html2html_strict)
  776. html = '<a href="mailto:john.smith2@example.com" style="color: blue; text-decoration: underline; ">john.smith@example.com</a>'
  777. #result = 'john.smith@example.com (mailto:john.smith2@example.com)'
  778. result = 'john.smith2@example.com'
  779. assert_equal(result, html.html2html_strict)
  780. html = '<img src="/some.png" style="color: blue; width: 30px; height: 50px">'
  781. result = '<img src="/some.png" style=" width: 30px; height: 50px;">'
  782. assert_equal(result, html.html2html_strict)
  783. html = '<img src="/some.png" width="30px" height="50px">'
  784. result = '<img src="/some.png" style="width:30px;height:50px;">'
  785. assert_equal(result, html.html2html_strict)
  786. html = '<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">'
  787. result = '<img style="width: 181px; height: 125px;" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">'
  788. assert_equal(result, html.html2html_strict)
  789. html = '<p class="MsoNormal"><a href="http://www.example.com/"><span style="color:blue;text-decoration:none"><img border="0" width="30" height="30" id="_x0000_i1030" src="cid:image001.png@01D172FC.F323CDB0"></span></a><o:p></o:p></p>'
  790. result = '<p><a href="http://www.example.com/" rel="nofollow noreferrer noopener" target="_blank" title="http://www.example.com/"><img border="0" src="cid:image001.png@01D172FC.F323CDB0" style="width:30px;height:30px;"></a></p>'
  791. assert_equal(result, html.html2html_strict)
  792. html = '<p><a style="color: " href="http://www.example.com/?wm=mail"><img border="0" src="cid:example_new.png@8B201D8C.000B" width="101" height="30"></a></p>'
  793. result = '<p><a href="http://www.example.com/?wm=mail" rel="nofollow noreferrer noopener" target="_blank" title="http://www.example.com/?wm=mail"><img border="0" src="cid:example_new.png@8B201D8C.000B" style="width:101px;height:30px;"></a></p>'
  794. assert_equal(result, html.html2html_strict)
  795. html = '<p><font size="2"><a style="color: " href="http://www.example.com/?wm=mail"><img border="0" src="cid:example_new.png@8B201D8C.000B" width="101" height="30"></a></font></p>'
  796. result = '<p><a href="http://www.example.com/?wm=mail" rel="nofollow noreferrer noopener" target="_blank" title="http://www.example.com/?wm=mail"><img border="0" src="cid:example_new.png@8B201D8C.000B" style="width:101px;height:30px;"></a></p>'
  797. assert_equal(result, html.html2html_strict)
  798. html = '<div class="">Wir brauchen also die Instanz <a href="http://example.zammad.com" class="">example.zammad.com</a>, kann die aber nicht mehr nutzen.</div><div class=""><br class=""></div><div class="">Bitte um Freischaltung.</div><div class=""><br class=""></div><div class=""><br class=""><div class="">'
  799. result = '<div>Wir brauchen also die Instanz <a href="http://example.zammad.com" rel="nofollow noreferrer noopener" target="_blank">example.zammad.com</a>, kann die aber nicht mehr nutzen.</div><div>&nbsp;</div><div>Bitte um Freischaltung.</div><div>&nbsp;</div>'
  800. assert_equal(result, html.html2html_strict)
  801. html = '<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D;mso-fareast-language:EN-US">oh jeee … Zauberwort vergessen ;-) Können Sie mir
  802. <b>bitte</b> noch meine Testphase verlängern?<o:p></o:p></span></p>
  803. <p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p>&nbsp;</o:p></span></p>'
  804. result = '<p>oh jeee … Zauberwort vergessen ;-) Können Sie mir <b>bitte</b> noch meine Testphase verlängern?</p><p>&nbsp;</p>'
  805. assert_equal(result, html.html2html_strict)
  806. html = '<div><a href="http://www.example.com/Community/Passwort-Vergessen/?module_fnc=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805" title="http://www.example.com/Community/Passwort-Vergessen/?module_fnc%5BextranetHandler%5D=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805" rel="nofollow" target="_blank">http://www.example.com/Community/Passwort-Vergessen/?module_fnc%5BextranetHandler%5D=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805</a></div>'
  807. result = '<div><a href="http://www.example.com/Community/Passwort-Vergessen/?module_fnc=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805" title="http://www.example.com/Community/Passwort-Vergessen/?module_fnc%5BextranetHandler%5D=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805" rel="nofollow noreferrer noopener" target="_blank">http://www.example.com/Community/Passwort-Vergessen/?module_fnc%5BextranetHandler%5D=ChangeForgotPassword&amp;pwchangekey=66901c449dda98a098de4b57ccdf0805</a></div>'
  808. assert_equal(result, html.html2html_strict)
  809. html = '<tr style="height: 15pt;" class=""><td width="170" nowrap="" valign="bottom" style="width: 127.5pt; border-style: none none none solid; border-left-width: 1pt; border-left-color: windowtext; padding: 0cm 5.4pt; height: 15pt;" class=""><p class="MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;"><span style="" class="">&nbsp;</span></p></td><td width="58" nowrap="" valign="bottom" style="width: 43.5pt; padding: 0cm 5.4pt; height: 15pt;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="" class="">20-29</span></div></td><td width="47" nowrap="" valign="bottom" style="width: 35pt; background-color: rgb(255, 199, 206); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="color: rgb(156, 0, 6);" class="">200</span></div></td><td width="76" nowrap="" valign="bottom" style="width: 57pt; background-color: rgb(255, 199, 206); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="color: rgb(156, 0, 6);" class="">-1</span></div></td><td width="76" nowrap="" valign="bottom" style="width: 57pt; border-style: none solid none none; border-right-width: 1pt; border-right-color: windowtext; background-color: rgb(255, 199, 206); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="color: rgb(156, 0, 6);" class="">201</span></div></td><td width="107" nowrap="" valign="bottom" style="width: 80pt; padding: 0cm 5.4pt; height: 15pt;" class=""></td><td width="85" nowrap="" valign="bottom" style="width: 64pt; padding: 0cm 5.4pt; height: 15pt;" class=""></td><td width="101" nowrap="" valign="bottom" style="width: 76pt; border-style: none solid solid; border-left-width: 1pt; border-left-color: windowtext; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><b class=""><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">country</span></b><span style="font-size: 11pt; font-family: Calibri, sans-serif;" class=""></span></div></td><td width="87" nowrap="" valign="bottom" style="width: 65pt; border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">Target (gross)</span></div></td><td width="123" nowrap="" valign="bottom" style="width: 92pt; border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">Remaining Recruits</span></div></td><td width="87" nowrap="" valign="bottom" style="width: 65pt; border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: windowtext; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt; height: 15pt; background-position: initial initial; background-repeat: initial initial;" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: \'Times New Roman\', serif; text-align: center;" class=""><span style="font-size: 10pt; font-family: Arial, sans-serif;" class="">Total Recruits</span></div></td></tr>'
  810. result = "<tr>
  811. <td valign=\"bottom\" style=\" border-style: none none none solid; border-left-width: 1pt; border-left-color: windowtext; padding: 0cm 5.4pt;\"><p>&nbsp;</p></td>
  812. <td valign=\"bottom\" style=\" padding: 0cm 5.4pt;\"><div>20-29</div></td>
  813. <td valign=\"bottom\" style=\" background-color: rgb(255, 199, 206); padding: 0cm 5.4pt;\"><span style=\"color: rgb(156, 0, 6);\">200</span></td>
  814. <td valign=\"bottom\" style=\" background-color: rgb(255, 199, 206); padding: 0cm 5.4pt;\"><span style=\"color: rgb(156, 0, 6);\">-1</span></td>
  815. <td valign=\"bottom\" style=\" border-style: none solid none none; border-right-width: 1pt; border-right-color: windowtext; background-color: rgb(255, 199, 206); padding: 0cm 5.4pt;\"><span style=\"color: rgb(156, 0, 6);\">201</span></td>
  816. <td valign=\"bottom\" style=\" padding: 0cm 5.4pt;\"></td>
  817. <td valign=\"bottom\" style=\" padding: 0cm 5.4pt;\"></td>
  818. <td valign=\"bottom\" style=\" border-style: none solid solid; border-left-width: 1pt; border-left-color: windowtext; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt;\"><div>
  819. <b>country</b>
  820. </div></td>
  821. <td valign=\"bottom\" style=\" border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt;\"><div>Target (gross)</div></td>
  822. <td valign=\"bottom\" style=\" border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: gray; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt;\"><div>Remaining Recruits</div></td>
  823. <td valign=\"bottom\" style=\" border-style: none solid solid none; border-bottom-width: 1pt; border-bottom-color: gray; border-right-width: 1pt; border-right-color: windowtext; background-color: rgb(242, 242, 242); padding: 0cm 5.4pt;\"><div>Total Recruits</div></td>
  824. </tr>"
  825. assert_equal(result, html.html2html_strict)
  826. html = "<div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div style=\"line-height:1.7;color:#000000;font-size:14px;font-family:Arial\"><div>Dear Bob<span style=\"line-height: 23.8px;\">:</span><span style=\"color: rgb(255, 255, 255); line-height: 1.7;\">Mr/Mrs</span></div><div><br></div><div><span style=\"line-height: 1.7;\">We&nbsp;are&nbsp;one&nbsp;of&nbsp;the&nbsp;leading&nbsp;manufacturer&nbsp;and&nbsp;supplier&nbsp;of&nbsp;</span>conduits and cars since 3000.</div><div><br></div><div>Could you inform me the specification you need?</div><div><br></div><div>May I sent you our products catalogues for your reference?</div><div><br></div><div><img src=\"cid:5cb2783c$1$15ae9b384c8$Coremail$zhanabcdzhao$example.com\" orgwidth=\"1101\" orgheight=\"637\" data-image=\"1\" style=\"width: 722.7px; height: 418px; border: none;\"></div><div>Best regards!</div><div><br></div><div><b style=\"line-height: 1.7;\"><i><u><span lang=\"EL\" style=\"font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#17365D;\nmso-ansi-language:EL\">Welcome to our booth B11/1 Hall 13 during SOMEWHERE\n9999.</span></u></i></b></div><div style=\"position:relative;zoom:1\"><div>Bob Smith</div><div><div>Exp. &amp; Imp.</div><div>Town Example Electric Co., Ltd.</div><div>Tel: 0000-11-12345678 (Ext-220) &nbsp;Fax: 0000-11-12345678&nbsp;</div><div>Room1234, NO. 638, Smith Road, Town, 200000, Somewhere</div><div>Web: www.example.com</div></div><div style=\"clear:both\"></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>"
  827. result = "<div>\n<div>Dear Bob:Mr/Mrs</div><div>&nbsp;</div><div>We are one of the leading manufacturer and supplier of conduits and cars since 3000.</div><div>&nbsp;</div><div>Could you inform me the specification you need?</div><div>&nbsp;</div><div>May I sent you our products catalogues for your reference?</div><div>&nbsp;</div><div><img src=\"cid:5cb2783c%241%2415ae9b384c8%24Coremail%24zhanabcdzhao%24example.com\" style=\"width: 722.7px; height: 418px;\"></div><div>Best regards!</div><div>&nbsp;</div><div><b><i><u>Welcome to our booth B11/1 Hall 13 during SOMEWHERE 9999.</u></i></b></div><div>\n<div>Bob Smith</div><div>\n<div>Exp. &amp; Imp.</div><div>Town Example Electric Co., Ltd.</div><div>Tel: 0000-11-12345678 (Ext-220) Fax: 0000-11-12345678</div><div>Room1234, NO. 638, Smith Road, Town, 200000, Somewhere</div><div>Web: www.example.com</div></div></div></div>"
  828. assert_equal(result, html.html2html_strict)
  829. html = '<li><a style="font-size:15px; font-family:Arial;color:#0f7246" class="text_link" href="http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NVTGVpNWZ8fGZh"><span style="color: rgb(0, 0, 0);">Luxemburg</span></a></li>'
  830. result = '<li><a href="http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NVTGVpNWZ8fGZh" rel="nofollow noreferrer noopener" target="_blank" title="http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NVTGVpNWZ8fGZh">Luxemburg</a></li>'
  831. assert_equal(result, html.html2html_strict)
  832. end
  833. test 'inline attachment replace' do
  834. html = '<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">'
  835. (body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
  836. assert_match(/<img style="width: 181px; height: 125px" src="cid:.+?">/, body)
  837. assert_equal(1, attachments_inline.count)
  838. assert_equal('image1.jpeg', attachments_inline[0][:filename])
  839. assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
  840. assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
  841. assert_equal('inline', attachments_inline[0][:preferences]['Content-Disposition'])
  842. html = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc">'
  843. (body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
  844. assert_match(/<img src="cid:.+?" style="width: 181px; height: 125px" alt="abc">/, body)
  845. assert_equal(1, attachments_inline.count)
  846. assert_equal('image1.jpeg', attachments_inline[0][:filename])
  847. assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
  848. assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
  849. assert_equal('inline', attachments_inline[0][:preferences]['Content-Disposition'])
  850. html = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc"><invalid what ever'
  851. (body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
  852. assert_match(/<img src="cid:.+?" style="width: 181px; height: 125px" alt="abc">/, body)
  853. assert_equal(1, attachments_inline.count)
  854. assert_equal('image1.jpeg', attachments_inline[0][:filename])
  855. assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
  856. assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
  857. assert_equal('inline', attachments_inline[0][:preferences]['Content-Disposition'])
  858. html = '<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">'
  859. (body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
  860. assert_match(/<img src="\/some_one.png" style="width: 181px; height: 125px" alt="abc">/, body)
  861. assert_equal(0, attachments_inline.count)
  862. html = '<div><img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..."><p>123</p><img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..."></div>'
  863. (body, attachments_inline) = HtmlSanitizer.replace_inline_images(html)
  864. assert_match(/<div>\s+<img style="width: 181px; height: 125px" src="cid:.+?"><p>123<\/p>\s+<img style="width: 181px; height: 125px" src="cid:.+?">\s+<\/div>/, body)
  865. assert_equal(2, attachments_inline.count)
  866. assert_equal('image1.jpeg', attachments_inline[0][:filename])
  867. assert_equal('image/jpeg', attachments_inline[0][:preferences]['Content-Type'])
  868. assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[0][:preferences]['Content-ID'])
  869. assert_equal('inline', attachments_inline[0][:preferences]['Content-Disposition'])
  870. assert_equal('image2.jpeg', attachments_inline[1][:filename])
  871. assert_equal('image/jpeg', attachments_inline[1][:preferences]['Content-Type'])
  872. assert_match(/@#{Setting.get('fqdn')}/, attachments_inline[1][:preferences]['Content-ID'])
  873. assert_equal('inline', attachments_inline[1][:preferences]['Content-Disposition'])
  874. end
  875. test 'set dynamic image size' do
  876. html = '<img style="width: 181px; height: 125px" src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/...">'
  877. body = HtmlSanitizer.dynamic_image_size(html)
  878. assert_match(/<img style="max-width:100%;width: 181px;max-height: 125px;" src="data:image.+?">/, body)
  879. html = '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/..." style="width: 181px; height: 125px" alt="abc">'
  880. body = HtmlSanitizer.dynamic_image_size(html)
  881. assert_match(/<img src="data:image.+?" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">/, body)
  882. html = '<img src="/some_one.png" style="width: 181px; height: 125px" alt="abc">'
  883. body = HtmlSanitizer.dynamic_image_size(html)
  884. assert_match(/<img src="\/some_one.png" style="max-width:100%;width: 181px;max-height: 125px;" alt="abc">/, body)
  885. html = '<img src="/some_one.png" alt="abc">'
  886. body = HtmlSanitizer.dynamic_image_size(html)
  887. assert_match(/<img src="\/some_one.png" alt="abc" style="max-width:100%;">/, body)
  888. end
  889. test 'signature_identify function' do
  890. marker_template = '######SIGNATURE_MARKER######'
  891. source = 'test'
  892. result = 'test'
  893. assert_equal(result, source.signature_identify('text', true))
  894. source = "test\n--\nend"
  895. result = "test\n#{marker_template}--\nend"
  896. assert_equal(result, source.signature_identify('text', true))
  897. source = "On 01/04/15 10:55, Bob Smith wrote:"
  898. result = "#{marker_template}On 01/04/15 10:55, Bob Smith wrote:"
  899. assert_equal(result, source.signature_identify('text', true))
  900. source = "Am 03.04.2015 um 20:58 schrieb Martin Edenhofer <me@znuny.ink>:"
  901. result = "#{marker_template}Am 03.04.2015 um 20:58 schrieb Martin Edenhofer <me@znuny.ink>:"
  902. assert_equal(result, source.signature_identify('text', true))
  903. source = "\ntest 123 \n1\n2\n3\n4\n5\n6\n7\n8\n9\n--\nBob Smith\n"
  904. result = "\ntest 123 \n1\n2\n3\n4\n5\n6\n7\n8\n9\n#{marker_template}--\nBob Smith\n"
  905. assert_equal(result, source.signature_identify('text', true))
  906. source = "test 123 \n--no not match--\n--\nBob Smith\n"
  907. result = "test 123 \n--no not match--\n#{marker_template}--\nBob Smith\n"
  908. assert_equal(result, source.signature_identify('text', true))
  909. source = "test 123 \n--no not match--\n -- \nBob Smith\n"
  910. result = "test 123 \n--no not match--\n#{marker_template} -- \nBob Smith\n"
  911. assert_equal(result, source.signature_identify('text', true))
  912. source = "test 123 \n\n--\nBob Smith\n\n\n\n\n--\nBob Smith\n"
  913. result = "test 123 \n#{marker_template}\n--\nBob Smith\n\n\n\n\n--\nBob Smith\n"
  914. assert_equal(result, source.signature_identify('text', true))
  915. source = "test 123\ntest 123\n--\nBob Smith\n"
  916. result = "test 123\ntest 123\n#{marker_template}--\nBob Smith\n"
  917. assert_equal(result, source.signature_identify('text', true))
  918. source = "test 123\ntest 123\n--\nBob Smith\n\n"
  919. result = "test 123\ntest 123\n#{marker_template}--\nBob Smith\n\n"
  920. assert_equal(result, source.signature_identify('text', true))
  921. # apple
  922. # en
  923. source = "test 123 \n--no not match--\nBob Smith\nOn 01/04/15 10:55, Bob Smith wrote:\nlalala\n--\nsome test"
  924. 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"
  925. assert_equal(result, source.signature_identify('text', true))
  926. # de
  927. 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"
  928. 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"
  929. assert_equal(result, source.signature_identify('text', true))
  930. # ms
  931. # en
  932. 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>"
  933. 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>"
  934. assert_equal(result, source.signature_identify('text', true))
  935. # de
  936. 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"
  937. 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"
  938. assert_equal(result, source.signature_identify('text', true))
  939. # fr
  940. 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"
  941. 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"
  942. assert_equal(result, source.signature_identify('text', true))
  943. marker_template = '<span class="js-signatureMarker"></span>'
  944. html = "lalala<br>--<br>Max Mix"
  945. result = "lalala#{marker_template}<br>--<br>Max Mix"
  946. assert_equal(result, html.html2html_strict)
  947. marker_template = '<span class="js-signatureMarker"></span>'
  948. html = "lalala<br/>--<br/>Max Mix"
  949. result = "lalala#{marker_template}<br>--<br>Max Mix"
  950. assert_equal(result, html.html2html_strict)
  951. marker_template = '<span class="js-signatureMarker"></span>'
  952. html = "lalala<br/>
  953. --<br/>Max Mix"
  954. result = "lalala#{marker_template}<br> --<br>Max Mix"
  955. assert_equal(result, html.html2html_strict)
  956. marker_template = '<span class="js-signatureMarker"></span>'
  957. html = "lalala<p>--</p>Max Mix"
  958. result = "lalala#{marker_template}<p>--</p>Max Mix"
  959. assert_equal(result, html.html2html_strict)
  960. marker_template = '<span class="js-signatureMarker"></span>'
  961. html = "lalala<br>__<br>Max Mix"
  962. result = "lalala#{marker_template}<br>__<br>Max Mix"
  963. assert_equal(result, html.html2html_strict)
  964. 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>Hello,<br><br>ich versuche an den Punkten"
  965. 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's<br><br>Hello,<br><br>ich versuche an den Punkten"
  966. assert_equal(result, html.html2html_strict)
  967. html = '<div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span lang="DE" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Von:</span></b><span lang="DE" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"> Martin Edenhofer via Zammad Helpdesk [mailto:<a href="mailto:support@example.com">support@zammad.com</a>] <br><b>Gesendet:</b> '
  968. result = '<span class="js-signatureMarker"></span><p><b>Von:</b> Martin Edenhofer via Zammad Helpdesk [mailto:support@example.com] <br><b>Gesendet:</b> </p>'
  969. assert_equal(result, html.html2html_strict)
  970. html = '<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
  971. <p class="MsoNormal" style="margin-left:35.4pt"><b><span style="font-family:Calibri;color:black">Von:
  972. </span></b><span style="font-family:Calibri;color:black">Johanna Kiefer via Znuny Projects &lt;projects@example.com&gt;<br>
  973. <b>Organisation: </b>Znuny Group<br>
  974. <b>Datum: </b>Montag, 6. März 2017 um 13:32<br>'
  975. result = '<div>
  976. <span class="js-signatureMarker"></span><p><b>Von: </b>Johanna Kiefer via Znuny Projects &lt;projects@example.com&gt;<br>
  977. <b>Organisation: </b>Znuny Group<br>
  978. <b>Datum: </b>Montag, 6. März 2017 um 13:32<br></p></div>'
  979. assert_equal(result, html.html2html_strict)
  980. html = '<div><br>
  981. <br>
  982. <br><font size=1 color=#5f5f5f face="sans-serif">Von: &nbsp; &nbsp; &nbsp;
  983. &nbsp;</font><font size=1 face="sans-serif">Hotel &lt;info@example.com&gt;</font>
  984. <br><font size=1 color=#5f5f5f face="sans-serif">An: &nbsp; &nbsp; &nbsp;
  985. &nbsp;</font></div>'
  986. result = '<span class="js-signatureMarker"></span><div><br>Von: Hotel &lt;info@example.com&gt; <br>An: </div>'
  987. assert_equal(result, html.html2html_strict)
  988. html = '<br class=""><div><blockquote type="cite" class=""><div class="">On 04 Mar 2017, at 14:47, Oliver Ruhm &lt;<a href="mailto:oliver@example.com" class="">oliver@example.com</a>&gt; wrote:</div><br class="Apple-interchange-newline">'
  989. result = '<div><span class="js-signatureMarker"></span><blockquote type="cite">
  990. <div>On 04 Mar 2017, at 14:47, Oliver Ruhm &lt;oliver@example.com&gt; wrote:</div><br>
  991. </blockquote></div>'
  992. assert_equal(result, html.html2html_strict)
  993. html = '<br class=""><div><blockquote type="cite" class=""><div class="">some note</div><br class="Apple-interchange-newline">'
  994. result = '<div><blockquote type="cite">
  995. <div>some note</div><br>
  996. </blockquote></div>'
  997. assert_equal(result, html.html2html_strict)
  998. html = '<div>
  999. <br> Am 17.03.2017 um 17:03 schrieb Martin Edenhofer via Zammad Helpdesk &lt;support@example.com&gt;:<br>
  1000. <br>
  1001. </div>'
  1002. result = '<div>
  1003. <br> Am 17.03.2017 um 17:03 schrieb Martin Edenhofer via Zammad Helpdesk &lt;support@example.com&gt;:<br>
  1004. <br>
  1005. </div>'
  1006. assert_equal(result, html.html2html_strict)
  1007. html = '<div>
  1008. <br> Am 17.03.2017 um 17:03 schrieb Martin Edenhofer via Zammad Helpdesk &lt;support@example.com&gt;:<br>
  1009. <br>
  1010. </div>
  1011. <blockquote type="cite">
  1012. <div>Dear Mr. Smith,<br></div>
  1013. </blockquote>'
  1014. result = '<span class="js-signatureMarker"></span><div>
  1015. <br> Am 17.03.2017 um 17:03 schrieb Martin Edenhofer via Zammad Helpdesk &lt;support@example.com&gt;:<br>
  1016. <br>
  1017. </div><blockquote type="cite">
  1018. <div>Dear Mr. Smith,<br>
  1019. </div></blockquote>'
  1020. assert_equal(result, html.html2html_strict)
  1021. end
  1022. end