[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: subject is deleted instead of rewritten

From: Dan Nelson
Subject: Re: subject is deleted instead of rewritten
Date: Thu, 9 Jan 2003 13:44:49 -0600
User-agent: Mutt/1.5.3i

In the last episode (Jan 09), Ronan Waide said:
> On January 9, address@hidden said:
> > anyway i hope that one of the developers read this thread and have
> > a look into it as well. i am not that used to c++, but we'll see.
> I'm constantly amused at the number of people involved with SAM who
> aren't C++ programmers per se. I had thought briefly about redoing
> the whole thing in C, since I understand C :)

Same for me; I know almost no C++.  The nice thing about C++ is that as
long as you stick to C++ types like <list>s and strings, you can simply
destroy the SpamAssassin object and all the associated data goes away
at the same time thanks to destructors.  No manual free()'ing lists of
headers, etc.

Back to the original subject:  the code has an extremely simplistic
header parser.  It searches for "\nHeadername: ", which means that the
first header never gets matched because it doesn't have a leading "\n".
Most of the time it's not a problem since messages will already have
some Received: headers added by the time they hit your server.

Actually, it might be really easy to fix.  The search is done at the
top of retrieve_field().  Something like this would fix the problem
(Note: code written on the fly, untested):

    string retrieve_field(const string& header, const string& field)
      // look for beginning of content
      string::size_type pos = cmp_nocase_partial(field, header)+string(": "));
      if (pos != 0) 
        pos = find_nocase(header, string("\n")+field+string(": "));

        // return empty string if not found
        if (pos == string::npos)
          debug(3, "r_f: failed");
          return string("");
    ... etc etc

First check to see if your 'field' is the first text in 'header'.  If
it is, good.  Otherwise do the "\nField: " test as usual.

        Dan Nelson

reply via email to

[Prev in Thread] Current Thread [Next in Thread]