cli tool: improve ";type=" handling in -F option arguments

This commit is contained in:
Patrick Monnerat 2017-10-29 14:31:03 +01:00 committed by monnerat
parent f82f952d2f
commit e240a546a7
1 changed files with 16 additions and 20 deletions

View File

@ -233,12 +233,10 @@ static int get_param_part(struct OperationConfig *config, char endchar,
} }
/* now point beyond the content-type specifier */ /* now point beyond the content-type specifier */
endpos = type + strlen(type_major) + strlen(type_minor) + 1; p = type + strlen(type_major) + strlen(type_minor) + 1;
for(p = endpos; ISSPACE(*p); p++) for(endct = p; *p && *p != ';' && *p != endchar; p++)
; if(!ISSPACE(*p))
while(*p && *p != ';' && *p != ',') endct = p + 1;
p++;
endct = p;
sep = *p; sep = *p;
} }
else if(checkprefix("filename=", p)) { else if(checkprefix("filename=", p)) {
@ -330,29 +328,27 @@ static int get_param_part(struct OperationConfig *config, char endchar,
sep = *p; sep = *p;
*endpos = '\0'; *endpos = '\0';
} }
else if(endct) {
/* This is part of content type. */
for(endct = p; *p && *p != ';' && *p != endchar; p++)
if(!ISSPACE(*p))
endct = p + 1;
sep = *p;
}
else { else {
/* unknown prefix, skip to next block */ /* unknown prefix, skip to next block */
char *unknown = get_param_word(&p, &endpos, endchar); char *unknown = get_param_word(&p, &endpos, endchar);
sep = *p; sep = *p;
if(endct) *endpos = '\0';
endct = p; if(*unknown)
else { warnf(config->global, "skip unknown form field: %s\n", unknown);
*endpos = '\0';
if(*unknown)
warnf(config->global, "skip unknown form field: %s\n", unknown);
}
} }
} }
/* Terminate and strip content type. */ /* Terminate content type. */
if(type) { if(endct)
if(!endct)
endct = type + strlen(type);
while(endct > type && ISSPACE(endct[-1]))
endct--;
*endct = '\0'; *endct = '\0';
}
if(ptype) if(ptype)
*ptype = type; *ptype = type;