Skip to content

Commit

Permalink
Fixes: #4583 - Align the mail client behavior for <title> tag with Za…
Browse files Browse the repository at this point in the history
…mmad
  • Loading branch information
mgruner committed May 24, 2024
1 parent 6bd2057 commit 152e336
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/initializers/html_sanitizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
comment
meta
script
title
]

# content of this tags will will be inserted html quoted
Expand Down
9 changes: 9 additions & 0 deletions spec/lib/html_sanitizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@
expect(described_class.strict('<table width=20><tr width=20><td width=20>123</td></tr></table>')).to eq('<table style="width:20px;"><tr style="width:20px;"><td style="width:20px;">123</td></tr></table>')
end
end

context 'when handling <title> tags' do
let(:source) { '<title>some title</title><p>actual content</p>' }
let(:target) { '<p>actual content</p>' }

it 'removes them' do
expect(described_class.strict(source)).to eq(target)
end
end
end

describe '.cleanup' do
Expand Down
1 change: 1 addition & 0 deletions test/data/mail/mail004.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ body: |+
content_type: text/plain
attachments: []
...
2 changes: 0 additions & 2 deletions test/data/mail/mail016.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ from_display_name: ''
to: '"enterprisemobility.apacservice" <enterprisemobility.apacservice@motorola.com>'
subject: "【 直通美国排名第49大学 成功后付费 】"
body: |-
新建网页 3
<span style=" color: blue;">
<div>您好,这封信如果影响到您的生活和工作,我们向您诚恳的道歉。</div><div>您回复此邮箱即可退订,以后绝对不会再次收到,</div><div>
<strong>再次祝福您工作顺利,婚姻美满,家庭幸福,生意兴隆。</strong> </div><div> </div></span>
Expand Down
1 change: 1 addition & 0 deletions test/data/mail/mail018.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ attachments:
Content-Type: message/rfc822
Mime-Type: message/rfc822
Charset: UTF-8
...
2 changes: 0 additions & 2 deletions test/data/mail/mail019.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ from_display_name: ''
to: 377861373 <377861373@qq.com>
subject: "《欧美简讯》"
body: |-
新建网页 4
<div>
<div>
<div>
Expand Down
1 change: 1 addition & 0 deletions test/data/mail/mail020.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,4 @@ attachments:
original-format: true
Mime-Type: text/html
Charset: windows-1252
...
2 changes: 1 addition & 1 deletion test/data/mail/mail023.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from: marketingmanager@nthcpghana.com
from_email: marketingmanager@nthcpghana.com
from_display_name: ''
to: ''
subject:
subject:
body: "机房环境法规\nMessage-ID: <20140911055224675615@nthcpghana.com>\nFrom: =?utf-8?B?6IOh5qW35ZKM?=
<marketingmanager@nthcpghana.com>\nTo: <spviex@126.com>,\n\t<kmdc.info@gmail.com>,\n\t<neeraj@atsindia.info>,\n\t<info@znuny.cn>,\n\t<info@merz.cz>,\n\t<admin@ealonline.org>,\n\t<office@korekt-bg.com>,\n\t<ps@techno-quest.net>,\n\t<xxxlkj@21cn.com>,\n\t<seo@yourtraffic.com>\nSubject:
=?utf-8?B?5LmY6aOO56C05rWq5Lya5pyJ5pe277yM55u05oyC5LqR5biG5rWO5rKn5rW344CCIuWIq+iuqeaArw==?=\n\t=?utf-8?B?5byx5ZCm5a6a6Ieq5bex77yM5Yir6K6p5oOr5oeS6K+v5LqG6Z2S5pil44CC5LiA5Liq5Lq66YOo5YiG?=\n\t=?utf-8?B?6YO95LiN6IO95pyJ5omA5oiQ5bCx77yM5LiA5Liq5Zu95a625LiN5aWL5paX5LiN6IO956uL6Laz5LiW?=\n\t=?utf-8?B?55WM77yM5LiA5Liq5rCR5peP5LiN5aWL5paX5LiN6IO95YW055ub5by65aSn44CC?=\nDate:
Expand Down
2 changes: 0 additions & 2 deletions test/data/mail/mail026.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ from_display_name: gate
to: Martin Edenhofer <billing@znuny.inc>
subject: Ihre Rechnung als PDF-Dokument
body: |-
Ihre Rechnung als PDF-Dokument
<table cellpadding="0" cellspacing="0" bgcolor="#d9e7f0" style="font-size: 12px;color: #000000;width: 100%;background-color: #d9e7f0;padding: 0px;margin: 0px;">
<tr>
<td valign="top">
Expand Down
1 change: 1 addition & 0 deletions test/data/mail/mail030.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,4 @@ attachments:
original-format: true
Mime-Type: text/html
Charset: UTF-8
...
1 change: 1 addition & 0 deletions test/data/mail/mail035.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ body: |+
content_type: text/plain
reply-to: firstfinanceloanfirm@example.com
attachments: []
...
1 change: 1 addition & 0 deletions test/data/mail/mail045.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ body: |+
content_type: text/plain
attachments: []
...
2 changes: 1 addition & 1 deletion test/data/mail/mail047.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to: info@example.de
subject: "-90%! Nur 3,90 statt 39,90 EUR: In-Ear-Stereo-Headset mit Bluetooth 4.1
und Magnetverschluss für Bob Max Example"
body: |-
HotPriceMail - -90%! Nur 3,90 statt 39,90 EUR: In-Ear-Stereo-Headset mit Bluetooth 4.1 und Magnetverschluss<table style="text-align:left !important;width:790px;" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" align="left"><table bgcolor="#eeeeee" cellpadding="0" cellspacing="0" border="0" style="width:790px;">
<table style="text-align:left !important;width:790px;" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td valign="top" align="left"><table bgcolor="#eeeeee" cellpadding="0" cellspacing="0" border="0" style="width:790px;">
<tr><td valign="top">
<table border="0" cellspacing="0" cellpadding="0" style="width:790px;">
<tr><td style="text-align: center;" align="center" colspan="8"><b>&gt; In-Ear-Stereo-Headset mit Bluetooth 4.1 und Magnetverschluss nur 3,90 EUR - jetzt supergünstig! &lt;</b></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion test/data/mail/mail049.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to: info@example.de
subject: 'Kinderschwimmbrille ABC Little Twist: Schnell angelegt, keine verhedderten
Haare (Pressemitteilung)'
body: |-
Kinderschwimmbrille 1ABCD Little Twist: Schnell angelegt, keine verhedderten Haare (Pressemitteilung) <span style="color:transparent;"> ● durchdachtes Kopfband für schnelles &amp; einfaches Anlegen ● die fröhliche &amp; farbenfrohe Gestaltung freut Kinder</span><span>
<span style="color:transparent;"> ● durchdachtes Kopfband für schnelles &amp; einfaches Anlegen ● die fröhliche &amp; farbenfrohe Gestaltung freut Kinder</span><span>
<span><span>
<span>
<span>
Expand Down
2 changes: 0 additions & 2 deletions test/data/mail/mail066.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ from_display_name: ABC GmbH
to: service@example.com
subject: ABC gratuliert!
body: |-
Glückwunschkarte
<p>Wenn diese Mail nicht richtig dargestellt wird, dann klicken Sie bitte <a href="http://www.example.com/wlabel/geburtstag/?id=0umjv6klh0skcp4j57kl3ro8jymo4c134rcbh31ezc3bk1wv&amp;xz=d%C2%E2%C6NvnDNoP%97%1D%FD%82%1F%00%21%E2%F3a%CEqH%40%0E%3E%2B%BDDI%C6&amp;nv=1337" rel="nofollow noreferrer noopener" target="_blank" title="http://www.example.com/wlabel/geburtstag/?id=0umjv6klh0skcp4j57kl3ro8jymo4c134rcbh31ezc3bk1wv&amp;xz=d%C2%E2%C6NvnDNoP%97%1D%FD%82%1F%00%21%E2%F3a%CEqH%40%0E%3E%2B%BDDI%C6&amp;nv=1337"><u>hier</u></a>.</p><table border="0" cellpadding="0" cellspacing="0" align="center" style="border:2px solid #ebebeb;width:660px;"> <tr style="background-color:#ffffff;"> <td> <img src="FF_Geburtstagsmail.jpg" alt="Herzlichen Glückwunsch !"> </td> </tr> <tr> <td style="background-color:#ffffff; padding:30px 30px 0 30px;"> <h1>Sehr geehrte Damen und Herren,</h1>
<p>zu Ihrem Geburtstag schicken wir Ihnen ein großes Paket mit guten Wünschen:<br> Viel Erfolg, Energie und ein gutes Gespür für die richtigen Entscheidungen!</p><p>Ihr Ehrentag ist ein guter Anlass zurückzublicken und sich an Erreichtem zu erfreuen. Doch er ist auch Anlass, den Blick nach vorne zu richten. Sich kurz zu orientieren und neue Ziele zu stecken. Unsere besten Wünsche begleiten Sie auf Ihrem zukünftigen Weg und wir freuen uns darauf, Ihnen auch dabei zur Seite zu stehen!</p><p>Heute wünschen wir Ihnen einen schönen Tag im Kreise Ihrer Freunde und Familie.</p><p>Herzliche Grüße</p><p>Ihre ABC</p></td> </tr> <tr> <td style="background-color:#ffffff; padding-left: 30px; font-size: 0.75em;"> <br>
Expand Down

0 comments on commit 152e336

Please sign in to comment.