Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-ID gets lost when parsing and then building an eml file #31

Open
cloudify opened this issue Feb 14, 2022 · 0 comments
Open

Content-ID gets lost when parsing and then building an eml file #31

cloudify opened this issue Feb 14, 2022 · 0 comments

Comments

@cloudify
Copy link

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch eml-format@0.6.1 for the project I'm working on.

The problem I've been facing is that if I just parse and build an eml file, without making any change, all the inline images break out - by looking at the content of the generated eml file I noticed that the Content-ID header gets lost in the process. Then I looked at the code and I noticed that during the parse step, the attach ID is stored in the id attribute while during the build step, the id is expected to be found in the cid attribute.

Here is the diff that solved my problem:

diff --git a/node_modules/eml-format/lib/eml-format.js b/node_modules/eml-format/lib/eml-format.js
index 575e557..412f02b 100644
--- a/node_modules/eml-format/lib/eml-format.js
+++ b/node_modules/eml-format/lib/eml-format.js
@@ -419,6 +419,8 @@ emlformat.build = function(data, options, callback) {
         eml += 'Content-Disposition: ' + (attachment.inline ? "inline" : "attachment") + '; filename="' + (attachment.filename || attachment.name || ("attachment_" + (i + 1))) + '"' + EOL;
         if (attachment.cid) {
           eml += 'Content-ID: <' + attachment.cid + ">" + EOL;
+        } else if (attachment.id) {
+          eml += 'Content-ID: <' + attachment.id + ">" + EOL;
         }
         eml += EOL;
         if (typeof attachment.data == "string") {

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant