[PATCH 3/4] reformime: don't skip to the (last) Content-Type before parsing tokens from headers

Joshua Judson Rosen jrosen at harvestai.com
Fri Oct 3 14:46:27 UTC 2014


On 2014-10-03 03:58, walter harms wrote:
>
>
> Am 02.10.2014 20:12, schrieb Joshua Judson Rosen:
>> The tokens we're looking for (like "name") occur in Content-Disposition,
>> and Content-Disposition may actually occur ahead of, or in the absence of,
>> any Content-Type header; for example in multipart/form-data from an HTTP POST.
>>
>> Signed-off-by: Joshua Judson Rosen <jrosen at harvestai.com>
>> ---
>>   mailutils/reformime.c |   11 ++---------
>>   1 file changed, 2 insertions(+), 9 deletions(-)
>>
>> diff --git a/mailutils/reformime.c b/mailutils/reformime.c
>> index 603f2bd..0f5d768 100644
>> --- a/mailutils/reformime.c
>> +++ b/mailutils/reformime.c
>> @@ -99,18 +99,11 @@ static int parse(const char *boundary, char **argv)
>>
>>   		/* Split to tokens */
>>   		{
>> -			char *s, *p;
>> +			char *s;
>>   			unsigned ntokens;
>>   			const char *delims = ";=\" \t\n";
>>
>> -			/* Skip to last Content-Type: */
>> -			s = p = header;
>> -			while ((p = strchr(p, '\n')) != NULL) {
>> -				p++;
>> -				if (strncasecmp(p, "Content-Type:", sizeof("Content-Type:")-1) == 0)
>> -					s = p;
>> -			}
>> -			dbg_error_msg("L:'%s'", p);
>> +			s = header;
>>   			ntokens = 0;
>>   			s = strtok(s, delims);
>
> why not
>     s = strtok(header, delims);
> do i miss something ?

Good point. No, you didn't miss anything--I did: the "s = header; s = strtok(s, 
delims);"
assignment is just a vestige of the  "s = p = header; ...; s = strtok(s, delims);"
construct from which I had just removed p.

I removed the "p =" from "s = p = header;" since the "p" var had obviously 
become obsolete,
but then I failed to notice that this also made the indirection between "s = 
header;"
and "strtok(s, delims);" obsolete.

-- 
"'tis an ill wind that blows no minds."


More information about the busybox mailing list