aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/main.c b/src/main.c
index d0bbdcdd7..862a9460b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2059,19 +2059,21 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
*/
char *p = strchr(nextarg, '=');
long size = 0;
- size_t nlen;
+ int nlen;
+ char is_file;
if(!p)
p = strchr(nextarg, '@');
- if(!p) {
- warnf(config, "bad use of --data-urlencode\n");
- return PARAM_BAD_USE;
+ if (p) {
+ nlen = p - nextarg; /* length of the name part */
+ is_file = *p++; /* pass the separator */
+ }
+ else {
+ nlen = is_file = -1;
+ p = nextarg;
}
- nlen = p - nextarg; /* length of the name part */
- if('@' == *p) {
+ if('@' == is_file) {
/* a '@' letter, it means that a file name or - (stdin) follows */
- p++; /* pass the separator */
-
if(curlx_strequal("-", p)) {
file = stdin;
SET_BINMODE(stdin);
@@ -2090,7 +2092,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
fclose(file);
}
else {
- GetStr(&postdata, ++p);
+ GetStr(&postdata, p);
size = strlen(postdata);
}
@@ -2108,8 +2110,10 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
char *n = malloc(outlen);
if(!n)
return PARAM_NO_MEM;
-
- snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
+ if (nlen > 0) /* only append '=' if we have a name */
+ snprintf(n, outlen, "%.*s=%s", nlen, nextarg, enc);
+ else
+ strcpy(n, enc);
curl_free(enc);
free(postdata);
if(n) {