From: Daniel Stenberg Date: Tue, 17 Dec 2024 06:52:06 +0000 (+0100) Subject: tool_formparse: accept digits in --form type= strings X-Git-Tag: curl-8_12_0~325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7e065f314f9d307af8f194a16c95cc754fefd4a;p=thirdparty%2Fcurl.git tool_formparse: accept digits in --form type= strings Adjusted test 186 to verify. Regression in 9664d5a5475fdc66, shipped in 8.11.1 Reported-by: IcedCoffeee on github Assisted-by: Jay Satiro Fixes #15761 Closes #15762 --- diff --git a/src/tool_formparse.c b/src/tool_formparse.c index ddbf1b1a74..814f240e66 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -495,14 +495,15 @@ static int get_param_part(struct OperationConfig *config, char endchar, ; if(!endct && checkprefix("type=", p)) { + size_t tlen; for(p += 5; ISSPACE(*p); p++) ; /* set type pointer */ type = p; /* find end of content-type */ - while(*p && (ISALPHA(*p) || (*p == '/') || (*p == '-'))) - p++; + tlen = strcspn(p, "()<>@,;:\\\"[]?=\r\n "); + p += tlen; endct = p; sep = *p; } diff --git a/tests/data/test186 b/tests/data/test186 index f5c071946f..006de79047 100644 --- a/tests/data/test186 +++ b/tests/data/test186 @@ -31,7 +31,7 @@ http HTTP RFC1867-type formposting with types on text fields -http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F "name=daniel;type=moo/foo" -F "html= hello;type=text/html;charset=verymoo" +http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F "name=daniel;type=moo/foo-.4" -F "html= hello;type=text/html;charset=verymoo" # We create this file before the command is invoked! @@ -46,12 +46,12 @@ POST /we/want/%TESTNUMBER HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -Content-Length: 338 +Content-Length: 341 Content-Type: multipart/form-data; boundary=----------------------------212d9006ceb5 ------------------------------212d9006ceb5 Content-Disposition: form-data; name="name" -Content-Type: moo/foo +Content-Type: moo/foo-.4 daniel ------------------------------212d9006ceb5