1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

parse_filename: strip trailing CRs and LFs

The feature that uses the file name given in a
Content-disposition: header didn't properly skip trailing
carriage returns and linefeed characters from the end of the file
name when it was given without quotes.
This commit is contained in:
Daniel Stenberg 2010-04-19 17:05:46 +02:00
parent a5b7e3205d
commit 47dda4a1d4

View File

@ -4200,9 +4200,26 @@ parse_filename(char *ptr, size_t len)
} }
} }
q = strrchr(p, quote); if(quote) {
if (q) /* if the file name started with a quote, then scan for the end quote and
*q = 0; stop there */
q = strrchr(p, quote);
if (q)
*q = 0;
}
else
q = NULL; /* no start quote, so no end has been found */
if(!q) {
/* make sure the file name doesn't end in \r or \n */
q = strchr(p, '\r');
if(q)
*q = 0;
q = strchr(p, '\n');
if(q)
*q = 0;
}
if (copy!=p) if (copy!=p)
memmove(copy, p, strlen(p)+1); memmove(copy, p, strlen(p)+1);