aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-04-19 17:05:46 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-04-19 17:05:46 +0200
commit47dda4a1d43c9341753388ab3babb0d27cf34840 (patch)
tree3bf026135dcdcba84880f5e77f7536c0f3cb634d /src/main.c
parenta5b7e3205d33f08e8c906e0c6337f09df20a0c4a (diff)
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.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 0670b5f5c..b7e438b1e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4200,9 +4200,26 @@ parse_filename(char *ptr, size_t len)
}
}
- q = strrchr(p, quote);
- if (q)
- *q = 0;
+ if(quote) {
+ /* if the file name started with a quote, then scan for the end quote and
+ 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)
memmove(copy, p, strlen(p)+1);