[PATCH 3/6] cli: make the hacky from guessing more liberal

Jani Nikula jani at nikula.org
Thu Oct 17 04:52:27 PDT 2013


On Thu, 17 Oct 2013, Mark Walters <markwalters1009 at gmail.com> wrote:
> On Wed, 16 Oct 2013, Jani Nikula <jani at nikula.org> wrote:
>> This is in preparation of switching to gmime header parsing. Accept
>> "for" and "by" preceded by tabs in the received header. This is a bit
>> flaky, but so is the whole guessing code.
>
> I am happy with the change but I think a little more explanation of the
> problem it fixes would be helpful. Is it that there could be a \n \t
> before the "for"/"by" or something else?

It's the same header folding by tabs here too. In your mail that I'm
replying to, the received headers are folded with tabs. (This may be due
to mailman doing bad things, but that's irrelevant.) There may be a tab
preceding the "for"/"by" instead of a space. Obviously this could be
made more robust, but if you look at what the from guessing does, you
realize it's quite hacky anyway, and a last resort. So I didn't bother,
at least not for now, for this series. Minimal change to make tests
pass.

>> ---
>>  notmuch-reply.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/notmuch-reply.c b/notmuch-reply.c
>> index 9d6f843..4b67e66 100644
>> --- a/notmuch-reply.c
>> +++ b/notmuch-reply.c
>> @@ -423,7 +423,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
>>      /* First we look for a " for <email at add.res>" in the received
>>       * header
>>       */
>> -    ptr = strstr (received, " for ");
>> +    ptr = strstr (received, "for ");
>
> The comment should be updated to match the code (and depending on the
> answer to the above maybe explain that too)

Agreed.

BR,
Jani.

>
> Best wishes
>
> Mark
>>  
>>      /* Note: ptr potentially contains a list of email addresses. */
>>      addr = user_address_in_string (ptr, config);
>> @@ -440,7 +440,7 @@ guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message
>>       * system in this step of the receive chain
>>       */
>>      by = received;
>> -    while((by = strstr (by, " by ")) != NULL) {
>> +    while((by = strstr (by, "by ")) != NULL) {
>>  	by += 4;
>>  	if (*by == '\0')
>>  	    break;
>> -- 
>> 1.8.4.rc3
>>
>> _______________________________________________
>> notmuch mailing list
>> notmuch at notmuchmail.org
>> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list