node-envelope icon indicating copy to clipboard operation
node-envelope copied to clipboard

erroneous parsing of from field

Open SebiTimeWaster opened this issue 6 years ago • 2 comments

raw email: From: "Almaifd, Tim" <[email protected]>

return:

from:
   [ { address: '"Almaifd', name: null },
     { address: '[email protected]', name: ' Tim"' } ],

should be:

from: { address: '[email protected]', name: 'Almaifd, Tim' },

SebiTimeWaster avatar Jun 23 '19 13:06 SebiTimeWaster

I see the spec defines this field at https://tools.ietf.org/html/rfc5322#section-3.6.2 with the mailbox-list rule and its derivatives at https://tools.ietf.org/html/rfc5322#section-3.4 . Unless you were planning on hand-coding a parser for this, might you wish to use pegjs? It can be fairly easily to just define the grammar and get a parser built for it.

brettz9 avatar Mar 03 '20 03:03 brettz9

I should note that this module was never really intended to be strictly standards-compliant (for that, it's probably better to use https://github.com/ronomon/mime, for example) – I just built it to process large batches of emails (that have been through validating systems previously) fairly quickly.

I am open to the idea to turn Envelope into a standards-compliant MIME message decoder / encoder though, and I guess the people using this module wouldn't mind that either :)

Unless you were planning on hand-coding a parser for this, might you wish to use pegjs? It can be fairly easily to just define the grammar and get a parser built for it.

I would indeed hand-roll parsers for these things, parser-generators (like pegjs) are too much cruft & overhead in these cases.

jhermsmeier avatar Mar 03 '20 07:03 jhermsmeier