Quantcast
Channel: ImapX 2
Viewing all articles
Browse latest Browse all 1952

Commented Unassigned: Bug when parsing header with duplicate keys [1701]

$
0
0
When parsing the headers, if the header name has already been found in the dictionary, the first line of the duplicated header is ignored with subsequent lines being appended to the end. This is particularly noticeable with the "Received" header which usually wraps and usually appears multiple times. So for example the following:

```
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: einsteintech **

Sorry I didn't reply sooner. If I email it, it'll probably just get caught in an attachment filter. Give this Dropbox link a try.

https://www.dropbox.com/s/169tiq99owgung8/EmailParser.cs


Viewing all articles
Browse latest Browse all 1952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>