diff options
-rw-r--r-- | src/tool_formparse.c | 54 | ||||
-rw-r--r-- | tests/data/Makefile.am | 2 |
2 files changed, 22 insertions, 34 deletions
diff --git a/src/tool_formparse.c b/src/tool_formparse.c index 5d6263e5c..ff2210ac8 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -73,9 +73,6 @@ * ***************************************************************************/ -#define FORM_FILE_SEPARATOR ',' -#define FORM_TYPE_SEPARATOR ';' - int formparse(struct Configurable *config, const char *input, struct curl_httppost **httppost, @@ -120,8 +117,8 @@ int formparse(struct Configurable *config, char *ptr; char *filename = NULL; - sep = strchr(contp, FORM_TYPE_SEPARATOR); - sep2 = strchr(contp, FORM_FILE_SEPARATOR); + sep = strchr(contp, ';'); + sep2 = strchr(contp, ','); /* pick the closest */ if(sep2 && (sep2 < sep)) { @@ -133,16 +130,13 @@ int formparse(struct Configurable *config, type = NULL; if(sep) { - - /* if we got here on a comma, don't do much */ - if(FORM_FILE_SEPARATOR == *sep) - ptr = NULL; - else - ptr = sep+1; + bool semicolon = (';' == *sep); *sep = '\0'; /* terminate file name at separator */ - while(ptr && (FORM_FILE_SEPARATOR!= *ptr)) { + ptr = sep+1; /* point to the text following the separator */ + + while(semicolon && ptr && (','!= *ptr)) { /* pass all white spaces */ while(ISSPACE(*ptr)) @@ -168,13 +162,17 @@ int formparse(struct Configurable *config, specified and if not we simply assume that it is text that the user wants included in the type and include that too up to the next zero or semicolon. */ - if((*sep==';') && !checkprefix(";filename=", sep)) { - sep2 = strchr(sep+1, ';'); - if(sep2) - sep = sep2; - else - sep = sep + strlen(sep); /* point to end of string */ + if(*sep==';') { + if(!checkprefix(";filename=", sep)) { + sep2 = strchr(sep+1, ';'); + if(sep2) + sep = sep2; + else + sep = sep + strlen(sep); /* point to end of string */ + } } + else + semicolon = FALSE; if(*sep) { *sep = '\0'; /* zero terminate type string */ @@ -186,9 +184,9 @@ int formparse(struct Configurable *config, } else if(checkprefix("filename=", ptr)) { filename = &ptr[9]; - ptr = strchr(filename, FORM_TYPE_SEPARATOR); + ptr = strchr(filename, ';'); if(!ptr) { - ptr = strchr(filename, FORM_FILE_SEPARATOR); + ptr = strchr(filename, ','); } if(ptr) { *ptr = '\0'; /* zero terminate */ @@ -199,20 +197,10 @@ int formparse(struct Configurable *config, /* confusion, bail out of loop */ break; } - /* find the following comma */ - if(ptr) - sep = strchr(ptr, FORM_FILE_SEPARATOR); - else - sep = NULL; - } - else { - sep = strchr(contp, FORM_FILE_SEPARATOR); - } - if(sep) { - /* the next file name starts here */ - *sep = '\0'; - sep++; + + sep = ptr; } + /* if type == NULL curl_formadd takes care of the problem */ if(!AddMultiFiles(contp, type, filename, &multi_start, diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 93faca212..5bb3725d8 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -81,7 +81,7 @@ test1208 test1209 test1210 test1211 \ test1220 \ test1300 test1301 test1302 test1303 test1304 test1305 \ test1306 test1307 test1308 test1309 test1310 test1311 test1312 test1313 \ -test1314 \ +test1314 test1315 \ test2000 test2001 test2002 test2003 test2004 EXTRA_DIST = $(TESTCASES) DISABLED |