Upgrade mail gem from 2.6.6 to 2.7-stable to solve 4 issues:

#2362 - Attached text files get prepended on e-mail reply instead of appended
#2507 - PDF Attachments are corrupted into blank pages
#2458 - Zammad fails to parse filename\* in Content-Disposition header of attachment
#2499 - eml-File Attachments will be destroyed by zammad
This commit is contained in:
Billy Zhou 2019-03-27 13:02:56 +01:00
parent 3acfa4a277
commit 30d3ce2b88
15 changed files with 20411 additions and 47 deletions

View file

@ -78,7 +78,7 @@ gem 'twitter', git: 'https://github.com/sferik/twitter.git'
# channels - email additions
gem 'htmlentities'
gem 'mail', git: 'https://github.com/zammad-deps/mail', branch: '2-6-stable-878-844'
gem 'mail', git: 'https://github.com/zammad-deps/mail', branch: '2-7-stable'
gem 'mime-types'
gem 'rchardet', '>= 1.8.0'
gem 'valid_email2'

View file

@ -32,11 +32,11 @@ GIT
GIT
remote: https://github.com/zammad-deps/mail
revision: 33a8a94028937e8664a7499d3486ffed59b898e6
branch: 2-6-stable-878-844
revision: 9265cf75bbe376f595944bd10d2dd953f863e765
branch: 2-7-stable
specs:
mail (2.6.7.pre)
mime-types (>= 1.16, < 4)
mail (2.7.2.edge)
mini_mime (>= 0.1.1)
GIT
remote: https://github.com/zammad-deps/tcr

View file

@ -72,7 +72,11 @@ class Channel::EmailParser
=end
def parse(msg)
mail = Mail.new(msg.force_encoding('binary'))
msg = msg.force_encoding('binary')
# mail 2.6 and earlier accepted non-conforming mails that lacked the correct CRLF seperators,
# mail 2.7 and above require CRLF so we force it on using binary_unsafe_to_crlf
msg = Mail::Utilities.binary_unsafe_to_crlf(msg)
mail = Mail.new(msg)
headers = message_header_hash(mail)
body = message_body_hash(mail)
@ -492,10 +496,13 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
begin
value = f.to_utf8
if value.blank?
value = f.raw_value.to_utf8
value = f.decoded.to_utf8
end
# fields that cannot be cleanly parsed fallback to the empty string
rescue Mail::Field::IncompleteParseError
value = ''
rescue
value = f.raw_value.to_utf8(fallback: :read_as_sanitized_binary)
value = f.decoded.to_utf8(fallback: :read_as_sanitized_binary)
end
[f.name.downcase, value]
end.to_h

View file

@ -1,7 +1,7 @@
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
from: '"Hans BÄKO Schönland" <me@bogen.net>'
from: '"Hans BÄKOSchönland" <me@bogen.net>'
from_email: me@bogen.net
from_display_name: Hans BÄKO Schönland
from_display_name: Hans BÄKOSchönland
subject: 'utf8: 使って / ISO-8859-1: Priorität" / cp-1251: Сергей Углицких'
content_type: text/html
body: '<p>this is a test</p><br><hr> <a href="http://localhost/8HMZENUS/2737??PS="

View file

@ -3,7 +3,7 @@ from: postmaster@example.com
from_email: postmaster@example.com
from_display_name: ''
to: sales@znuny.org
subject: Benachrichtung zum +ANw-bermittlungsstatus (Fehlgeschlagen)
subject: "Benachrichtung \tzum \t+ANw-bermittlungsstatus \t(Fehlgeschlagen)"
body: |+
Dies ist eine automatisch erstellte Benachrichtigung +APw-ber den Zustellstatus.

View file

@ -47,3 +47,283 @@ body: |-
</table>
</td></tr></table>
<br>Unsubscribe from newsletter: <a href="http://business-catalogs.example.com/c2JudXVlcmNic2I4MWk7MTgxOTMyNS1jMmMtNzA=" rel="nofollow noreferrer noopener" target="_blank" title="http://business-catalogs.example.com/c2JudXVlcmNic2I4MWk7MTgxOTMyNS1jMmMtNzA=">Click here</a>
content_type: text/html
reply-to: Paula <databases.en@example.com>
attachments:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
data: "<style type=\"text/css\">body { padding: 5px 5px 5px 5px; margin: 0px; background-color:
#ffffff;} body, td { font-size: 12px; font-family: Arial, Verdana, sans-serif;
} .Bold { font-weight: bold; } .Title { font-weight: bold; font-size: 18px; color:
#cc3300; } .Code { border: #8b4513 1px solid; padding-right: 5px; padding-left:
5px; color: #000066; font-family: 'Courier New' , Monospace; background-color:
#ff9933; } </style><center><table border=\"0\" width=\"600\"><tr><td><center>\n<table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n <tbody>\n
\ <tr>\n <td align=\"center\" valign=\"top\">\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"560\">\n <tbody>\n
\ <tr>\n <td width=\"560\" height=\"10\">&nbsp;</td>\n
\ </tr>\n </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" bgcolor=\"#ffffff\" width=\"560\"
style=\"border-style:solid;; border-width:3px;border-color:#16b99b; border-collapse:
collapse; border-spacing: 0;\">\n <tbody>\n <tr>\n
\ <td align=\"center\" width=\"560\">\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"560\">\n <tbody>\n
\ <tr>\n <td
align=\"center\" width=\"560\"><a href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnaWVpLGUzZHx4bnxlZWY%3D\"
style=\"border: none;\"><img border=\"0\" width=\"560\" height=\"172\" src=\"http://business-catalogs.example.com/YjhtaTsxMTE5Zzg1LTMyNztjLWNuMGFtMmlfZ2xpc2VtaWc5Mi83YWgvYTg5ckNlZWRnLy5Ic2pw\"
style=\"display: block;\" alt=\"\" /></a></td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"560\">\n <tbody>\n
\ <tr>\n <td
width=\"560\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p><span style=\"color: rgb(255, 102, 0);\"><i>Geben
Sie diese Information an den Direktor oder den für Marketing und Umsatzsteigerung
verantwortlichen Mitarbeiter Ihrer Firma weiter!</i></span></p>\n </td>\n
\ </tr>\n <tr>\n
\ <td width=\"520\" height=\"10\">&nbsp;</td>\n
\ </tr>\n </tbody>\n
\ </table>\n <table cellspacing=\"0\"
cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" style=\"border-top-style:solid; ;border-color:#c7c7c7; border-top-width:3px\">\n
\ <table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p>Hallo,</p>\n <ul>\n
\ <li>Sie suchen nach Möglichkeiten, den
Umsatz Ihre Firma zu steigern?</li><li>Sie brauchen neue Geschäftskontakte?</li><li>Sie
sind es leid, Kontaktdaten manuell zu erfassen?</li><li>Ihr Kontaktdatenanbieter
ist zu teuer oder Sie sind mit seinen Dienstleistungen unzufrieden?</li><li>Sie
möchten Ihre Kontaktinformationen gern effizienter auf dem neuesten Stand halten?</li>
\ </ul>\n <p><br
/>Bei uns können Sie mit nur wenigen Clicks <b>Geschäftskontakte</b> verschiedener
Länder erwerben.</p>\n <p>Dies ist eine <b>schnelle
und bequeme</b> Methode, um Daten zu einem vernünftigen Preis zu erhalten.</p>\n
\ <p>Alle Daten werden <b>ständig aktualisiert</b>m
so dass Sie sich keine Sorgen machen müssen.</p>\n <p>&nbsp;</p>\n
\ </td>\n </tr>\n
\ <tr>\n <td
width=\"520\" height=\"10\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"center\" width=\"520\">\n <table cellspacing=\"0\"
cellpadding=\"0\" border=\"0\" width=\"340\">\n <tbody>\n
\ <tr>\n <td
width=\"113\"><a href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0LnNzdXJobGZzZWVsdGEtLm10cmVzb2YvY2VtL2xpZ25pYWlnaV9hbC9zOG1lOXgyOTdzZW1hL2VlL2xwZWxheHB4Q18ubXhzfEhsODh8Y2M%3D\"
style=\"border: none;\"><img border=\"0\" width=\"113\" height=\"125\" src=\"http://business-catalogs.example.com/YjhtaTsxMTE5Zzg1LTMyNztjLWNuMGFtMmlfZ2xpc2VtaWc5Mi83YXIvczg5ZTVlemkyXzc3ZGM3ODg3ai4yZjEwZ3A%3D\"
style=\"display: block;\" alt=\"\" /></a></td>\n <td
width=\"20\">&nbsp;</td>\n <td
width=\"75\"><img border=\"0\" width=\"75\" height=\"125\" src=\"http://business-catalogs.example.com/YjhtaTsxMTE5Zzg1LTMyNztjLWNuMGFtMmlfZ2xpc2VtaWc5Mi83YXIvczg5ZTVlemlhXzc3ZGU0Yjg3ai44OTA1Z3A%3D\"
style=\"display: block;\" alt=\"\" /></td>\n <td
width=\"20\">&nbsp;</td>\n <td
width=\"112\"><a href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnaWVpLGUzZHx4bnxlZWY%3D\"
style=\"border: none;\"><img border=\"0\" width=\"112\" height=\"125\" src=\"http://business-catalogs.example.com/YjhtaTsxMTE5Zzg1LTMyNztjLWNuMGFtMmlfZ2xpc2VtaWc5Mi83YXIvczg5ZTVlemllXzc3ZGRhOTg3ai4zMGZmZ3A%3D\"
style=\"display: block;\" alt=\"\" /></a></td>\n </tr>\n
\ <tr>\n <td
height=\"10\">&nbsp;</td>\n </tr>\n
\ <tr>\n <td
align=\"left\" width=\"113\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p style=\"text-align: center;\"><a
href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0LnNzdXJobGZzZWVsdGEtLm10cmVzb2YvY2VtL2xpZ25pYWlnaV9hbC9zOG1lOXgyOTdzZW1hL2VlL2xwZWxheHB4Q18ubXhzfEhsODh8Y2M%3D\"
class=\"text_link\" style=\"font-size:15px; font-family:Arial;color:#0f7246\">XLS-Muster
herunterladen<br />\n </a></p>\n
\ </td>\n <td
width=\"20\">&nbsp;</td>\n <td
align=\"left\" width=\"75\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">&nbsp;</td>\n
\ <td width=\"20\">&nbsp;</td>\n
\ <td align=\"left\" width=\"112\"
valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p style=\"text-align: center;\"><a
href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnaWVpLGUzZHx4bnxlZWY%3D\"
class=\"text_link\" style=\"font-size:15px; font-family:Arial;color:#0f7246\">Datenbank
bestellen<br />\n </a></p>\n </td>\n
\ </tr>\n </tbody>\n
\ </table>\n </td>\n
\ </tr>\n <tr>\n
\ <td height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p style=\"text-align: center;\"><span style=\"color:
rgb(255, 102, 0);\"><b>Die Anmeldung ist absolut kostenlos und unverbindlich.</b>
Sie können die Kataloge gemäß Ihren eigenen Kriterien filtern und ein kostenloses
Datenmuster bestellen, sobald Sie sich angemeldet haben.</span><span class=\"new\"><br
/>\n </span></b></p>\n </td>\n
\ </tr>\n <tr>\n
\ <td width=\"520\" height=\"10\">&nbsp;</td>\n
\ </tr>\n </tbody>\n
\ </table>\n <table cellspacing=\"0\"
cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" style=\"border-top-style:solid; ;border-color:#c7c7c7; border-top-width:3px\">\n
\ <table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p><span style=\"color: rgb(0, 0, 0);\"> <b>Wir
haben Datenbanken der folgenden Länder:</b>&nbsp;</span></p>\n <table
width=\"100%\">\n <tbody>\n <tr>\n
\ <td>\n <ul>\n
\ <li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NUQWVpMjZ8fGEx\"><span
style=\"color: rgb(0, 0, 0);\">Österreich</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NFQmVpYzR8fGNh\"><span
style=\"color: rgb(0, 0, 0);\">Belgien</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NZQmVpMGJ8fDAw\"><span
style=\"color: rgb(0, 0, 0);\">Belarus</span></a></li>\n <li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NIQ2VpYjF8fGY4\"><span
style=\"color: rgb(0, 0, 0);\">Schweiz</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NaQ2VpMTZ8fDc1\"><span
style=\"color: rgb(0, 0, 0);\">Tschechische Republik</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NFRGVpMDl8fDM1\"><span
style=\"color: rgb(0, 0, 0);\">Deutschland</span></a></li><li><a style=\"font-size:15px;
font-fa\n mily:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NFRWVpYTd8fGNm\"><span
style=\"color: rgb(0, 0, 0);\">Estland</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NSRmVpNGN8fDBl\"><span
style=\"color: rgb(0, 0, 0);\">Frankreich</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NCR2VpNjh8fDA4\"><span
style=\"color: rgb(0, 0, 0);\">Vereinigtes Königreich</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"tex\n t_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NVSGVpNDB8fGQx\"><span
style=\"color: rgb(0, 0, 0);\">Ungarn</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NFSWVpNDd8fGNi\"><span
style=\"color: rgb(0, 0, 0);\">Irland</span></a></li> </ul>\n
\ </td>\n <td>\n
\ <ul>\n <li><a
style=\"font-size:15px; font-family:Arial;color:#0f7246\" class=\"text_link\"
href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NUSWVpOTJ8fDU3\"><span
style=\"color: rgb(0, 0, 0);\">Italien</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NJTGVpNTF8fDlk\"><span
style=\"color: rgb(0, 0, 0);\">Liechtenstein</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NUTGVpN2R8fDgw\"><span
style=\"color: rgb(0, 0, 0);\">Litauen</span></a></l\n i><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><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NWTGVpZWZ8fDE2\"><span
style=\"color: rgb(0, 0, 0);\">Lettland</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NMTmVpOTV8fDQw\"><span
style=\"color: rgb(0, 0, 0);\">Niederlande</span></a></li><li><a style=\"font-size:15px;
font-family:Aria\n l;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NMUGVpNGV8fDBm\"><span
style=\"color: rgb(0, 0, 0);\">Polen</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NVUmVpZTV8fGVk\"><span
style=\"color: rgb(0, 0, 0);\">Russland</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NJU2VpN2R8fGYz\"><span
style=\"color: rgb(0, 0, 0);\">Slowenien</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://busine\n ss-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NLU2VpNjZ8fDQ5\"><span
style=\"color: rgb(0, 0, 0);\">Slowakei</span></a></li><li><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnY25pLGUsdXJ0b3NBVWVpYTd8fDNh\"><span
style=\"color: rgb(0, 0, 0);\">Ukraine</span></a></li> </ul>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ <tr>\n <td
width=\"520\" height=\"10\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" style=\"border-top-style:solid; ;border-color:#c7c7c7; border-top-width:3px\">\n
\ <table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p style=\"text-align: center;\"><span style=\"font-size:
18px;\">Anwendungsmöglichkeiten für Geschäftskontakte<br />\n <br
/>\n </span></p>\n <ul>\n
\ <li><i>Newsletter senden</i> - Senden
von Werbung per E-Mail (besonders effizient).</li><li><i>Telemarketing</i> - Telefonwerbung.</li><li><i>SMS-Marketing</i>
- Senden von Kurznachrichten.</li><li><i>Gezielte Werbung</i> - Briefpostwerbung.</li><li><i>Marktforschung</i>
- Telefonumfragen zur Erforschung Ihrer Produkte oder Dienstleistungen.</li> </ul>\n
\ <p>&nbsp;</p>\n <p><span
style=\"color: rgb(31, 114, 70);\"><span style=\"font-size: 16px;\">Sie können
<b>Abschnitte wählen (filtern)</b> Empfänger gemäß Tätigkeitsbereichen und Standort
der Firmen, um die Effizienz Ihrer Werbemaßnahmen zu erhöhen.</span></span></p>\n
\ <p>&nbsp;</p>\n </td>\n
\ </tr>\n <tr>\n
\ <td width=\"520\" height=\"10\">&nbsp;</td>\n
\ </tr>\n </tbody>\n
\ </table>\n <table cellspacing=\"0\"
cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" style=\"border-top-style:solid; ;border-color:#c7c7c7; border-top-width:3px\">\n
\ <table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ <p style=\"text-align: center;\"><span style=\"color:
rgb(255, 0, 0);\">Für jeden Kauf von <b>2016-11-05 23:59:59</b> </span></p>\n
\ <p style=\"text-align: center;\"><span style=\"color:
rgb(255, 0, 0);\">wir gewähren <b>30%</b> Rabatt</span></p>\n <p
style=\"text-align: center;\"><span style=\"font-size: 17px;\"><span style=\"color:
rgb(255, 0, 0);\"><b>RABATTCODE: WZ2124DD</b></span></span></p>\n </td>\n
\ </tr>\n <tr>\n
\ <td width=\"520\" height=\"10\">&nbsp;</td>\n
\ </tr>\n </tbody>\n
\ </table>\n <table cellspacing=\"0\"
cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" style=\"border-top-style:solid; ;border-color:#c7c7c7; border-top-width:3px\">\n
\ <table cellspacing=\"0\" cellpadding=\"0\"
border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
width=\"520\" height=\"20\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n
\ </td>\n </tr>\n
\ </tbody>\n </table>\n <table
cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"520\">\n <tbody>\n
\ <tr>\n <td
align=\"left\" width=\"520\" valign=\"top\" style=\"font-size:15px; font-family:Arial;color:#222222;line-height:19px\">\n
\ \n <p><span
style=\"font-size: 15px;\"><b>Bestellen Sie online bei:</b><br />\n </span></p>\n
\ <p><span style=\"font-size: 15px;\"><a style=\"font-size:15px;
font-family:Arial;color:#0f7246\" class=\"text_link\" href=\"http://business-catalogs.example.com/ODtpbGs5MWIzbjUyYzExLTA4Yy06Mmg7N3AvL3R0bmFvY3B0LXlhbW9sc2Nhb3NnYy5lL3RpbXJlZi9lbS9ycnJuaWFpZXMsdGxnaWVpLGUzZHx4bnxlZWY%3D\">company-catalogs.com</a><br
/>\n </span></p>\n <p><span
style=\"font-size: 15px;\"><b>Für weitere Informationen:</b><br />\n </span></p>\n
\ <p><span style=\"font-size: 15px;\">E-Mail:
</span><span style=\"font-size: 15px;\"><a style=\"font-size:15px; font-family:Arial;color:#0f7246\"
class=\"text_link\" href=\"mailto:databases.en@example.com\"><span style=\"font-size:
15px;\"><b>databases.en@example.com</b></span></a></span><span style=\"font-size:
15px;\"><br />\n Telefon: +370-52-071554 (languages:
EN, PL, RU, LT)</span></p>\n </td>\n </tr>\n
\ <tr>\n <td
width=\"520\" height=\"10\">&nbsp;</td>\n </tr>\n
\ </tbody>\n </table>\n </td>\n
\ </tr>\n </tbody>\n </table>\n &nbsp;<br
/>\n &nbsp;</td>\n </tr>\n </tbody>\n</table>\n</center></td></tr></table><br><center><span
style=\"font-family: Arial;font-size:11px;color:#000000;\">Unsubscribe from newsletter:
<a href=\"http://business-catalogs.example.com/c2JudXVlcmNic2I4MWk7MTgxOTMyNS1jMmMtNzA%3D\"
style=\"color:#000000;\">Click here</a></span></center><br><br>"
filename: message.html
preferences: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
content-alternative: true
original-format: true
Mime-Type: text/html
Charset: UTF-8

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
from: '"Hans BÄKO Schönland" <me@bogen.net>'
from: '"Hans BÄKOSchönland" <me@bogen.net>'
from_email: me@bogen.net
from_display_name: Hans BÄKO Schönland
from_display_name: Hans BÄKOSchönland
to: Namedyński (hans@example.com)
subject: test email
body: |-

View file

@ -0,0 +1,26 @@
Sender: Martin von Wittich <redacted@redacted>
Message-ID: <f43f065c222c18bd8adf2b6597e89024@redacted>
Date: Tue, 29 Jan 2019 22:42:09 +0100
Subject: UTF-8-Attachment-Test
From: Martin von Wittich <redacted@redacted>
To: zammad <redacted@redacted>
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="_=_swift_1548798129_e1966f90b1db46de031aa1a8234266a8_=_"
X-Mailer: IServ v3
--_=_swift_1548798129_e1966f90b1db46de031aa1a8234266a8_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Regression test case for issue #2458 - Zammad fails to parse filename* in Content-Disposition header of attachment
--_=_swift_1548798129_e1966f90b1db46de031aa1a8234266a8_=_
Content-Type: text/plain; name="=?utf-8?Q?Erkl=C3=A4rung=2Etxt?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename*=utf-8''Erkl%C3%A4rung.txt
SGVsbG8gV29ybGQK
--_=_swift_1548798129_e1966f90b1db46de031aa1a8234266a8_=_--

View file

@ -0,0 +1,21 @@
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
from: Martin von Wittich <redacted@redacted>
from_email: redacted@redacted
from_display_name: Martin von Wittich
to: zammad <redacted@redacted>
subject: UTF-8-Attachment-Test
body: 'Regression test case for issue #2458 - Zammad fails to parse filename* in Content-Disposition
header of attachment
'
content_type: text/plain
attachments:
- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
data: 'Hello World
'
filename: Erklärung.txt
preferences: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
Content-Type: text/plain; name="=?utf-8?Q?Erkl=C3=A4rung=2Etxt?="
Mime-Type: text/plain
Charset: UTF-8

19840
test/data/mail/mail082.box Normal file

File diff suppressed because it is too large Load diff

102
test/data/mail/mail082.yml Normal file

File diff suppressed because one or more lines are too long

View file

@ -56,13 +56,25 @@ class EmailBuildTest < ActiveSupport::TestCase
)
text_should = <<~MSG_TEXT.chomp
> Welcome!
>
> Thank you for installing Zammad. äöüß
>
> Welcome!\r
>\r
> Thank you for installing Zammad. äöüß\r
>\r
MSG_TEXT
assert_equal(text_should, mail.text_part.body.to_s)
assert_equal(html, mail.html_part.body.to_s)
html_should = <<~MSG_HTML.chomp
<!DOCTYPE html>\r
<html>\r
<head>\r
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\r
</head>\r
<body style="font-family:Geneva,Helvetica,Arial,sans-serif; font-size: 12px;">\r
<div>&gt; Welcome!</div><div>&gt;</div><div>&gt; Thank you for installing Zammad. äöüß</div><div>&gt;</div>\r
</body>\r
</html>
MSG_HTML
assert_equal(html_should, mail.html_part.body.to_s)
parser = Channel::EmailParser.new
data = parser.parse(mail.to_s)
@ -113,7 +125,13 @@ class EmailBuildTest < ActiveSupport::TestCase
],
)
assert_equal(text, mail.text_part.body.to_s)
text_should = <<~MSG_TEXT.chomp
> Welcome!\r
>\r
> Thank you for installing Zammad. äöüß\r
>\r
MSG_TEXT
assert_equal(text_should, mail.text_part.body.to_s)
assert_nil(mail.html_part)
assert_equal('image/png; filename=somename.png', mail.attachments[0].content_type)
@ -193,7 +211,13 @@ class EmailBuildTest < ActiveSupport::TestCase
],
)
assert_equal(text, mail.text_part.body.to_s)
text_should = <<~MSG_TEXT.chomp
> Welcome!\r
>\r
> Thank you for installing Zammad. äöüß\r
>\r
MSG_TEXT
assert_equal(text_should, mail.text_part.body.to_s)
assert_nil(mail.html_part)
assert_equal('text/calendar; filename=schedule.ics', mail.attachments[0].content_type)
@ -232,7 +256,13 @@ class EmailBuildTest < ActiveSupport::TestCase
body: text,
)
assert_equal(text, mail.body.to_s)
text_should = <<~MSG_TEXT.chomp
> Welcome!\r
>\r
> Thank you for installing Zammad. äöüß\r
>\r
MSG_TEXT
assert_equal(text_should, mail.body.to_s)
assert_nil(mail.html_part)
parser = Channel::EmailParser.new
@ -309,4 +339,62 @@ text
end
# #2362 - Attached text files get prepended on e-mail reply instead of appended
test 'plain email + text attachment' do
ticket1 = Ticket.create!(
title: 'some article text attachment test',
group: Group.lookup(name: 'Users'),
customer_id: 2,
state: Ticket::State.lookup(name: 'new'),
priority: Ticket::Priority.lookup(name: '2 normal'),
updated_by_id: 1,
created_by_id: 1,
)
assert(ticket1, 'ticket created')
article1 = Ticket::Article.create!(
ticket_id: ticket1.id,
from: 'some_sender@example.com',
to: 'some_recipient@example.com',
subject: 'some subject',
message_id: 'some@id',
content_type: 'text/html',
body: 'some message article helper test1 <div><img style="width: 85.5px; height: 49.5px" src="cid:15.274327094.140938@zammad.example.com">asdasd<img src="cid:15.274327094.140939@zammad.example.com"><br>',
internal: false,
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
type: Ticket::Article::Type.find_by(name: 'email'),
updated_by_id: 1,
created_by_id: 1,
)
text = <<~MSG_TEXT.chomp
> Welcome!
>
> Email Content
MSG_TEXT
store1 = Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: 'Text Content',
filename: 'text_file.txt',
preferences: {
'Mime-Type' => 'text/plain'
},
created_by_id: 1,
)
mail = Channel::EmailBuild.build(
from: 'sender@example.com',
to: 'recipient@example.com',
body: text,
attachments: [
store1
],
)
File.write('append_test.eml', mail.to_s)
# Email Content should appear before the Text Content within the raw email
assert_match(/Email Content[\s\S]*Text Content/, mail.to_s)
end
end

View file

@ -666,7 +666,7 @@ Some Text",
result: {
0 => {
priority: '2 normal',
title: '【专业为您注册香港及海外公司(好处多多)】                                                                                                                                                                                                                                     ',
title: "Subject: 【专业为您注册香港及海外公司(好处多多)】#{' ' * 220}",
},
1 => {
body: 'Some Text',
@ -3029,7 +3029,7 @@ Some Text',
title: 'some subject 3',
},
1 => {
from: '=?windows-1258?B?VmFuZHJvbW1lLCBGculk6XJpYw==?= <fvandromme@example.com>',
from: '"Vandromme, Frédéric" <fvandromme@example.com>',
sender: 'Customer',
type: 'email',
body: 'Some Text',