vmime icon indicating copy to clipboard operation
vmime copied to clipboard

Bug in file attachments 63-74 characters long (9884-4-72-24698)

Open jjohnson-airlink opened this issue 11 years ago • 1 comments

I am having a problem with file attachments that have filenames between 63 and 74 characters long.

My filename looks like this:

1234567890123456789012345678901234567890123456789012345678901234.txt70

But my email looks like this:

Content-Description: 1234567890123456789012345678901234567890123456789012345678901234.txt70 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=1234567890123456789012345678901234567890123456789012345678901234;

The code looks like this:

file_attch = vmime::create vmime::fileAttachment ("/tmp/" + string(basename(this->attachment_names[jj].c_str())),

                                       vmime::mediaType(this->attachment_types[jj]),    

                                       vmime::text(this->attachment_descriptions[jj])                

                                                                 );

mb.appendAttachment(file_attch);

vmime::ref vmime::message msg = mb.construct();

this->raw_email = msg->generate();

This seems to be a bug where if the filename length is within 10 of the maxLineLength, then the file gets truncated. After 74 characters, the filename gets split into 2 or more lines.

jjohnson-airlink avatar Jun 09 '14 22:06 jjohnson-airlink

Hi!

I can't manage to reproduce the problem using a minimal source code. Could you try compiling, linking and running the following code against your VMime source tree?

class parameterizedHeaderFieldTest : public vmime::parameterizedHeaderField
{
public:

    // vmime::parameterizedHeaderField default constructor is protected
    parameterizedHeaderFieldTest()
        : parameterizedHeaderField()
    {
    }
};

int main()
{
    parameterizedHeaderFieldTest f;
    f.setName("Content-Disposition");
    f.setValue(vmime::make_shared <vmime::contentDisposition>("attachment"));
    f.appendParameter(vmime::make_shared <vmime::parameter>("filename",
        "1234567890123456789012345678901234567890123456789012345678901234.txt70"));

    vmime::generationContext ctx(vmime::generationContext::getDefaultContext());
    ctx.setMaxLineLength(vmime::lineLengthLimits::convenient);

    std::ostringstream oss;
    vmime::utility::outputStreamAdapter adapter(oss);

    f.generate(ctx, adapter);

    std::cout << oss.str() << std::endl;

    return 0;
}

By the way, which version of VMime are you using?

Thanks,

Vincent

vincent-richard avatar Jun 10 '14 20:06 vincent-richard