Closed miknaz closed 3 years ago
Thanks for submitting this. I have not tested, but believe this may be caused by a bug in how we handle continuations. We introduced some code that attempts to detect incorrect continuations (aka headers with an accidental space in front of them), and it may be getting confused here.
If you have time, you could try building the mime-dump
command in our repo, and running it against this email. Then remove one of the multi-line headers and see if it still triggers. Once we know which header is triggering it, we can figure out how to fix enmime. If you don't have time or inclination to do this, I will take a crack at it on the weekend.
My money's on this header right here being the problem:
DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=libertycomc.com; q=dns/txt;
s=krs; t=1603674005; h=Content-Transfer-Encoding: Mime-Version:
Content-Type: Subject: From: To: Message-Id: Sender: Date;
bh=faAL8rCmOc2K1K3IP+7qQSPKUakoqX/vM3mtikLFN0I=; b=TfJm39aZ1YvR3TVhRaf5BOcqO6N5ED/Kch55jvSrHK95UTu6KuKpHzAamCG9yJ4ithTOrC53
2qQhp5E+1c7Jyt7FMAYxKXhApcqBWd7wj5lmytO+ceEb+x6+BcgmWg2+knuXwexuDlYCFxKM
fwnBUlp5eb5+Mr3YmWVOptF/r7c=
@dcormier yes yes you are right ! I also removed this header and then I don't get the error! Need to fix it somehow )
Given the discussions we had in #159 -- I am in favor of removing the header continuation smarts entirely. Better to just follow the RFCs.
@jhillyerd oh sorry I did not go so deeply into RFC. Can you, please, explain me exactly what it means. I guess long headers split with some char like '\n'. And RFCs provides some valid characters to split long headers ?
@jhillyerd, by that do you mean reverting both #149 and #166?
Can you, please, explain me exactly what it means. I guess long headers split with some char like '\n'. And RFCs provides some valid characters to split long headers ?
Yeah, @miknaz. The RFCs provide for folding headers across multiple lines by using \r\n
followed by horizontal whitespace (one or more space or tab characters). The rest of that line is considered a continuation of the header from the previous line.
Since this package tries to handle emails that don't quite conform to the RFCs, one of the things in it currently is to try to catch headers that are just incorrectly indented, rather than being actual header continuation lines (since this is something we saw in some real emails in production, which lead @requaos to write #149 to handle that).
@dcormier thank you for the explanation! But as I understand guys here suggest to revert some fixes in package ? Or what the ways to fix this do we have ?
@dcormier Yeah, I think reverting both of those (preserving any good test cases that would still pass) is the best way forward.
If we find samples that fail after that, perhaps just making our individual header parsing more tolerant to that scenario would work better.
I'm just catching up on the changes in #166 and #159
Hi guys! Let me clarify if somebody is going to fix this in near time and we can expect new update or ? Because I would not like to try it by myself to not destroy something) but otherwise I will need to try to fix it ..(
I will likely give it a shot this weekend, although it should be simple fix. enmime has very good unit test coverage, so it will let you know if you broke it. :)
Please test with new master branch and let us know if this is resolved, then we can cut a release.
@jhillyerd yeah now I don't get that error! Good job, great thank you !
What I did: parsed some mimes
What I expected: to get parsed object
What I got: error
Release or branch I am using: [0.8.2] - 2020-10-10
(Please attach a sample message if you feel it will help reproduce the issue)
First of all, thank for the helpful package! But I get error when I parse some mimes:
expected slash after first token
I parse them like this:enmime.ReadEnvelope(strings.NewReader(mime))
Can you suggest me please how to avoid this problem ? Below is the example of mime which gives error: