andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Message ending in = sign has problem in DecodeQuotedPrintable #69

Closed 537mfb closed 12 years ago

537mfb commented 12 years ago

I just download the last version of Master branch and right away i get an issue with it

I had received an e-mail that ended on an = sign, and i would get an exception on it at DecodeQuotedPrintable (Utilities.cs)

The problem was that you have there the following code:

var eq = Convert.ToByte('=');
var n = 0;
for (int i = 0; i < data.Length; i++) {
    var b = data[i];

    if ((b == eq) {
        byte b1 = data[i + 1], b2 = data[i + 2];

and with data ending in an equals sign it would go in the if block and throw an exception trying to access

data[i + 1]

(wich doesn't exist)

changing the if into

if ((b == eq) && (i < data.Length - 2)) {

Solves the issue - at least at first glance - some more testing is required

537mfb commented 12 years ago

Both proposed and submited solutions work equally as far as i can see so i will just close this issue