Menu

#47 Message headers are encoded incorrectly

open
nobody
None
5
2007-10-22
2007-10-22
Anonymous
No

Blat encodes message headers completely if there is any character that needs encoding. It should not encode addresses, though.

See:

http://www.faqs.org/rfcs/rfc2047.html

+ An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'.

This is an example how it should do it:

From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>

Microsoft Exchange Server does not accept From if the address is encoded, too.

I implemented a simple fix that handles the case with only one address, but To, Cc and Bcc can have several addresses. The complete fix is not that simple.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    void fixup(char * string, Buf * outString, int headerLen, int linewrap, int noAddr)
    {
    int doBase64;
    int i, qLen, bLen;
    Buf outS;
    Buf fixupString;
    Buf tempstring;
    size_t charsetLen;
    int stringOffset;

    #if BLAT_LITE
    #else
    char savedEightBitMimeSupported;
    char savedBinaryMimeSupported;

    savedEightBitMimeSupported = eightBitMimeSupported;
    savedBinaryMimeSupported = binaryMimeSupported;
    #endif

    charsetLen = strlen( charset );
    if ( !charsetLen )
    charsetLen = strlen( defaultCharset );

    charsetLen += 7; // =? ?Q? ?=

    stringOffset = 0;
    tempstring.Add( string );
    outS = "";

    if ( CheckIfNeedQuotedPrintable((unsigned char *)tempstring.Get(), TRUE ) ) {
    Buf tmpstr;
    Buf bufAddr;
    unsigned char * pStr;

    fixupString.Clear();

    if (noAddr) { // An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'.
    if (tempstring.Get()[tempstring.Length()-1] == '>') {
    char *addr = strrchr(tempstring.Get(), '<');
    if (addr && addr > tempstring.Get() && addr[-1] == ' ') {
    addr--;
    bufAddr.Add(addr);
    tempstring.SetLength(addr - tempstring.Get());
    *tempstring.GetTail() = 0;
    }
    }
    }

    i = tempstring.Length();
    qLen = GetLengthQuotedPrintable((unsigned char *)tempstring.Get(), TRUE );
    ...
    outS.Add(tmpstr);
    outS.Add("?=");
    outS.Add(bufAddr);
    ...

     
  • Chip

    Chip - 2008-03-15

    Logged In: YES
    user_id=800692
    Originator: NO

    Have you tried my latest version? I should have this fixed already.

     

Log in to post a comment.

MongoDB Logo MongoDB