```
Received: I am a long header. I will tend to wrap. See
I have wrapped.
Blah: Blah
Received: I am another long header. I also tend to wrap
but you won't see the previous line.
```
When parsed, becomes (in the dictionary):
```
{"Received", "I am a long header. I will tend to wrap. See
I have wrapped.
but you won't see the previous line."}
```
One of the lines is missing. The bug appears in the EmailParser.ParseHeaders method. The code should read:
```
if ( !this._headersCollection.ContainsKey( trimmedText2 ) ) {
this._headersCollection.Add( trimmedText2, trimmedText3 );
}
else {
this._headersCollection[trimmedText2] += "\r\n" + trimmedText3;
}
```
The else branch currently is not present.
Also, when unfolding the wrapped header line, wouldn't it be better to remove the newline and collapse the whitespace? I've attached an updated copy of the EmailParser class from the version 2.0.0.9 release.
I would submit a pull request but I gotta plead ignorant here, I am really not familiar at all with contributing to open source projects and I have no idea where to even start. Hopefully this helps though.
Comments: ** Comment from web user: pavel_azanov **
Hi einsteintech!
thank you for reporting the issue and also providing a fix. I'll include it in the repository until the new version of the library is released.
Currently i'm rewriting the parsing engine completely, and the header parsing has been already optimized to handle multiline headers and headers with duplicate keys. In the new version of the library the parsing of this headers:
Received: I am a long header. I will tend to wrap. See
I have wrapped.
Blah: Blah
Received: I am another long header. I also tend to wrap
but you won't see the previous line.
will result in:
[
{ "received" : "I am a long header. I will tend to wrap. See I have wrapped. \r\n I am another long header. I also tend to wrap but you won't see the previous line." },
{ "blah": "blah" }
]
Multiline headers will be combined, and if there's any duplicate - it will be appended on a new line.
What do you think about it?