From 498cc15aa988fa8a37c98bbcdacf593a86bee087 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 15 Feb 2018 15:54:14 +0800 Subject: [PATCH] Upgrade mail gem to drop dependency on `mime-types`. Boot Memory Usage ``` Total allocated: 225695379 bytes (1990663 objects) Total retained: 32795116 bytes (291607 objects) ``` ``` Total allocated: 218342892 bytes (1897350 objects) Total retained: 30123426 bytes (261198 objects) ``` --- .gitattributes | 7 +- Gemfile | 1 - Gemfile.lock | 8 +- spec/fixtures/emails/encoded_display_name.eml | 22 +-- spec/fixtures/emails/forwarded_email_3.eml | 36 ++--- spec/fixtures/emails/inline_image.eml | 152 +++++++++--------- .../emails/reply_with_8bit_encoding.eml | 24 +-- 7 files changed, 124 insertions(+), 126 deletions(-) diff --git a/.gitattributes b/.gitattributes index ae7015b472a..546b134a0ce 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,14 @@ # Set default behaviour, in case users don't have core.autocrlf set. * text=auto -# Explicitly declare text files we want to always be normalized and converted +# Treat email fixtures as binary files so CRLF are not converted to LF. +*.eml binary + +# Explicitly declare text files we want to always be normalized and converted # to native line endings on checkout. *.yml text -# Custom for Visual Studio, very unlikely, but lets keep it +# Custom for Visual Studio, very unlikely, but lets keep it *.cs diff=csharp *.sln merge=union *.csproj merge=union diff --git a/Gemfile b/Gemfile index cf250465649..3db4f98f0a8 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,6 @@ else end gem 'mail' -gem 'mime-types', require: 'mime/types/columnar' gem 'mini_mime' gem 'mini_suffix' diff --git a/Gemfile.lock b/Gemfile.lock index 09d9ff3bb30..79ba711e6b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -162,16 +162,13 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) lru_redux (1.1.0) - mail (2.6.6) - mime-types (>= 1.16, < 4) + mail (2.7.0) + mini_mime (>= 0.1.1) memory_profiler (0.9.10) message_bus (2.1.2) rack (>= 1.1.3) metaclass (0.0.4) method_source (0.8.2) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) mini_mime (0.1.3) mini_portile2 (2.3.0) mini_racer (0.1.15) @@ -442,7 +439,6 @@ DEPENDENCIES mail memory_profiler message_bus - mime-types mini_mime mini_racer mini_suffix diff --git a/spec/fixtures/emails/encoded_display_name.eml b/spec/fixtures/emails/encoded_display_name.eml index 1b5d6bb3a10..132e4404011 100644 --- a/spec/fixtures/emails/encoded_display_name.eml +++ b/spec/fixtures/emails/encoded_display_name.eml @@ -1,11 +1,11 @@ -Return-Path: -From: =?UTF-8?B?0KHQu9GD0YfQsNC50L3QsNGP?= =?UTF-8?B?INCY0LzRjw==?= -To: meat@bar.com -Subject: I need help -Date: Fri, 15 Jan 2016 00:12:43 +0100 -Message-ID: <29@foo.bar.mail> -Mime-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -Будьте здоровы! +Return-Path: +From: =?UTF-8?B?0KHQu9GD0YfQsNC50L3QsNGP?= =?UTF-8?B?INCY0LzRjw==?= +To: meat@bar.com +Subject: I need help +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <29@foo.bar.mail> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +Будьте здоровы! diff --git a/spec/fixtures/emails/forwarded_email_3.eml b/spec/fixtures/emails/forwarded_email_3.eml index 1f37822b0a7..549dd44a68b 100644 --- a/spec/fixtures/emails/forwarded_email_3.eml +++ b/spec/fixtures/emails/forwarded_email_3.eml @@ -1,18 +1,18 @@ -Message-ID: <60@foo.bar.mail> -From: Ba Bar -To: Team -Date: Mon, 9 Dec 2016 13:37:42 +0100 -Subject: Fwd: Ça Discourse ? - -@team, can you have a look at this email below? - -Objet: Ça Discourse ? -Date: 2017-01-04 11:27 -De: Un Français -À: ba@bar.com - -Bonjour, - -Ça Discourse bien aujourd'hui ? - -Bises +Message-ID: <60@foo.bar.mail> +From: Ba Bar +To: Team +Date: Mon, 9 Dec 2016 13:37:42 +0100 +Subject: Fwd: Ça Discourse ? + +@team, can you have a look at this email below? + +Objet: Ça Discourse ? +Date: 2017-01-04 11:27 +De: Un Français +À: ba@bar.com + +Bonjour, + +Ça Discourse bien aujourd'hui ? + +Bises diff --git a/spec/fixtures/emails/inline_image.eml b/spec/fixtures/emails/inline_image.eml index af3283702a9..b169f8167a0 100644 --- a/spec/fixtures/emails/inline_image.eml +++ b/spec/fixtures/emails/inline_image.eml @@ -1,76 +1,76 @@ -Return-Path: -From: Foo Bar -To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com -Date: Fri, 15 Jan 2016 00:12:43 +0100 -Message-ID: <28@foo.bar.mail> -Mime-Version: 1.0 -Content-Type: multipart/related; boundary=001a114b2eccff183a052998ec68 - ---001a114b2eccff183a052998ec68 -Content-Type: multipart/alternative; boundary=001a114b2eccff1836052998ec67 - ---001a114b2eccff1836052998ec67 -Content-Type: text/plain; charset=UTF-8 - -Before - -[image: 内嵌图片 1] - -After - ---001a114b2eccff1836052998ec67 -Content-Type: text/html; charset=UTF-8 - -
Before

内嵌图片 1

After -
- ---001a114b2eccff1836052998ec67-- ---001a114b2eccff183a052998ec68 -Content-Type: image/png; name="logo.png" -Content-Disposition: inline; filename="logo.png" -Content-Transfer-Encoding: base64 -Content-ID: -X-Attachment-Id: ii_1525434659ddb4cb - -iVBORw0KGgoAAAANSUhEUgAAAPQAAABCCAMAAABXYgukAAABhlBMVEUAAAAjHyAjHyAjHyAjHyAj -HyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAAqVAAru/lGyTxXCL/+a5UHiHZGyTq -NyPtRCM7HyHwWCLrPCOEHSL95Z31g0W1HCMgs1wAqnghKC0Aq5YJirsAqm6oHCMPb5QArccUXnsS -Z4hAvWj80ouP1oXoKyR4HSL0eTz4q2j+76XsQCOf24vpLyNsHiJgHiEYTGHyZiucHSPzcDTf76IL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2IndlaGBODRAPoKna7xOanINy -0GNflHefT4OUOXwmQDaGhtbCoFSXFkYhNnRKuaG8fOhlB0DdQA+MHEhNOmRjH0MDKqdU2kiEde1S -zWpylk2wlDx291YZ8tdBrOcx8wN0HEbQrkDye7QKDvQVWBbQYOmovBed1j3IezkxW4U++u0BqE0v -Dp0C4t3bCfKr16HKzEgBNMdrhHWVzke0wrtRco3ZBdD4tintb36+oOSxn9KMdXEhhny0/fTFi+3t -R0FHb2I3vz2Gh3758C5+y47o5WTY18xBhyW0aAyNDXC5bGJmBP3rbEq8+ubhu403r4JMq69j5PD2 -deTDokRGMTOeTObHw8RUrti43uNBJ4aGW4r7AV/Ho0gM/XtE/MfinY37t1fWtx6H4cbr5cVIz+/8 -+S6M9XYTxxmGhlkzDGpkEQfYPI7qp9X9DuMJF56JY3t6Ism+ZaLpNjYsPNfP1+nJv/7+59+t891T -4/X1t6GsJ5tLaN9I8q1Yvvo/eBl/EK7kL9mNIpFO+9hHZR+y8W+KXjq2vtIBf3J681luXFlfYc6h -eOV7GJkb/5d5+KCbjaGDZlZjiKChwA8RNEx1hwcanvIPGbThAPKQQBvQuQ4FtKeb8GrOQOg/pxLS -uIDrr6oAAAAASUVORK5CYII= ---001a114b2eccff183a052998ec68-- +Return-Path: +From: Foo Bar +To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <28@foo.bar.mail> +Mime-Version: 1.0 +Content-Type: multipart/related; boundary=001a114b2eccff183a052998ec68 + +--001a114b2eccff183a052998ec68 +Content-Type: multipart/alternative; boundary=001a114b2eccff1836052998ec67 + +--001a114b2eccff1836052998ec67 +Content-Type: text/plain; charset=UTF-8 + +Before + +[image: 内嵌图片 1] + +After + +--001a114b2eccff1836052998ec67 +Content-Type: text/html; charset=UTF-8 + +
Before

内嵌图片 1

After +
+ +--001a114b2eccff1836052998ec67-- +--001a114b2eccff183a052998ec68 +Content-Type: image/png; name="logo.png" +Content-Disposition: inline; filename="logo.png" +Content-Transfer-Encoding: base64 +Content-ID: +X-Attachment-Id: ii_1525434659ddb4cb + +iVBORw0KGgoAAAANSUhEUgAAAPQAAABCCAMAAABXYgukAAABhlBMVEUAAAAjHyAjHyAjHyAjHyAj +HyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAjHyAAqVAAru/lGyTxXCL/+a5UHiHZGyTq +NyPtRCM7HyHwWCLrPCOEHSL95Z31g0W1HCMgs1wAqnghKC0Aq5YJirsAqm6oHCMPb5QArccUXnsS +Z4hAvWj80ouP1oXoKyR4HSL0eTz4q2j+76XsQCOf24vpLyNsHiJgHiEYTGHyZiucHSPzcDTf76IL +ga7qMyMwuGIArdEaQ1T7yIJwzHn2l1f6vnovHyDuTCPNHCQfMTr3oV/wVCL5tHEHk8gArKDnJyTv +UCIAruUWVW4ArLMQrlYNeKEEnNVQwm0cOkcAq4KA0X/mHyQAqVoArKkAq4wCpeIArdvnIyT1jU4A +qmQUXV3v9KikRSHP6pwwIyBHHiHKUSLxaDTtSCMCpLpgx3PaHyTtSSy/5Zetw3b83JSVSiT0i1eg +MSI+qVa2JCMrbVbiX0Ygs2YArL2LkGApkWQLf2kSZmpFMZD0AAAAEHRSTlMAEFCAv8+vQCBw72CP +358w5xEcGAAABxJJREFUeF7lmuW/uzoMh1eKrUApbMfd9efu7u5u193d739+gbHQBtg49x3b99U5 +H7asD0mTNNAoE9GobohUukmtxqDLbhoCi5nOICNruigWc+0BRXY80UN8ELEtQ/QWo4OGTFzRX4Y/ +UMy+ISqpOUi7mYmK4oPDLKpLJ4PBzMVOZAwEdVNgje6dmZ+fX5vZ+1mhrwcwto+stTKNnRgdxH3t +q0B7r6W4d/fEirivHR24HE48Ja47yO+NX22nujlxuDU/ialrXq9NmWUmQd7TIQZNTX9zBCczGYCy +mjVrmoxyIgnrDvLJS5d3jUSa3XXr/fbU+Ayipvi2mTUMbmAeT5AvJcCgy3P3fkbUNrTs6QWrNtAU +Mb+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ply_with_8bit_encoding.eml b/spec/fixtures/emails/reply_with_8bit_encoding.eml index ed99f6752a8..2d025dd929b 100644 --- a/spec/fixtures/emails/reply_with_8bit_encoding.eml +++ b/spec/fixtures/emails/reply_with_8bit_encoding.eml @@ -1,12 +1,12 @@ -Return-Path: -From: Foo Bar -To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com -Date: Fri, 15 Jan 2016 00:12:43 +0100 -Message-ID: <43@foo.bar.mail> -MIME-Version: 1.0 -Content-Type: text/plain; charset=iso-8859-1 -Content-Disposition: inline -Content-Transfer-Encoding: 8bit - -hab vergessen kritische zeichen einzufügen: -äöüÄÖÜß +Return-Path: +From: Foo Bar +To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com +Date: Fri, 15 Jan 2016 00:12:43 +0100 +Message-ID: <43@foo.bar.mail> +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit + +hab vergessen kritische zeichen einzufügen: +äöüÄÖÜß