--- spamass-milter.cpp.orig Wed Aug 14 11:15:10 2002 +++ spamass-milter.cpp Wed Oct 23 13:10:50 2002 @@ -88,6 +88,10 @@ #include <string> #include <iostream> #include <fstream> +using std::string; +using std::cout; +using std::cerr; +using std::endl; #ifdef __cplusplus extern "C" { @@ -293,6 +297,26 @@ const_cast<char*>(assassin->spam_checker_version().c_str())); + // Content-Type header // + // find it: + string string1; + string string2; + + string1 = retrieve_field(assassin->d().substr(0, eoh), string("Content-Type")); + string2 = assassin->content_type(); + + old = assassin->set_content_type(string2); + + if (string1 != string2) + { + if (old > 0) + smfi_chgheader(ctx,"Content-Type",1,string1.size() > 0 ? + const_cast<char*>(string1.c_str()) : NULL ); + else if (assassin->content_type().size()>0) + smfi_addheader(ctx, "Content-Type", + const_cast<char*>(string1.c_str())); + } + // // If SpamAssassin thinks it is spam, replace // Subject: @@ -322,23 +346,6 @@ smfi_addheader(ctx, "Subject", const_cast<char*>(newstring.c_str())); - - // Content-Type header // - // find it: - newstring = retrieve_field(assassin->d().substr(0, eoh), string("Content-Type")); - oldstring = assassin->content_type(); - - old = assassin->set_content_type(oldstring); - - // change if old one was present, append if non-null - if (old > 0 && newstring != oldstring) - smfi_chgheader(ctx,"Content-Type",1,newstring.size() > 0 ? - const_cast<char*>(newstring.c_str()) : NULL ); - else if (assassin->content_type().size()>0) - smfi_addheader(ctx, "Content-Type", - const_cast<char*>(newstring.c_str())); - - // Replace body with the one SpamAssassin provided // string::size_type body_size = assassin->d().size() - bob; unsigned char* bodyp = (unsigned char*) @@ -368,8 +375,12 @@ // look for end of field name pos = find_nocase(header, string(" "), pos) + 1; - // look for end of content + // return empty string if \n is at pos string::size_type pos2(pos); + if (pos2 == find_nocase(header, string("\n"), pos2)) + return string(""); + + // look for end of content do { pos2 = find_nocase(header, string("\n"), pos2+1);