formdata: use the mime-content type function #2282

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants
@bagder
Member

bagder commented Feb 4, 2018

Reduce code duplication by making Curl_mime_contenttype available and
used by the formdata function. This also makes the formdata function
recognize a set of more file extensions by default.

PR #2280 brought this to my attention.

formdata: use the mime-content type function
Reduce code duplication by making Curl_mime_contenttype available and
used by the formdata function. This also makes the formdata function
recognize a set of more file extensions by default.

PR #2280 brought this to my attention.
lib/formdata.c
@@ -627,9 +573,14 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
!form->contenttype) {
char *f = form->flags & HTTPPOST_BUFFER?
form->showfilename : form->value;
+ char const *type = prevtype;
+ if(!type)

This comment has been minimized.

@monnerat

monnerat Feb 5, 2018

Collaborator

To stay compatible, prevtype should be used only if Curl_mime_contenttype(f) return NULL.

@monnerat

monnerat Feb 5, 2018

Collaborator

To stay compatible, prevtype should be used only if Curl_mime_contenttype(f) return NULL.

This comment has been minimized.

@bagder

bagder Feb 5, 2018

Member

Oops, you're right. Thanks. I'll fix!

@bagder

bagder Feb 5, 2018

Member

Oops, you're right. Thanks. I'll fix!

@bagder bagder closed this in 84ad1fd Feb 5, 2018

@bagder bagder deleted the bagder/mime-contenttype branch Feb 9, 2018

@curl curl locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.