mirror of
https://github.com/curl/curl.git
synced 2026-08-25 12:23:44 +03:00
lib: sanitize conditional exclusion around MIME
The introduction of CURL_DISABLE_MIME came with some additional bugs: - Disabled MIME is compiled-in anyway if SMTP and/or IMAP is enabled. - CURLOPT_MIMEPOST, CURLOPT_MIME_OPTIONS and CURLOPT_HTTPHEADER are conditioned on HTTP, although also needed for SMTP and IMAP MIME mail uploads. In addition, the CURLOPT_HTTPHEADER and --header documentation does not mention their use for MIME mail. This commit fixes the problems above. Closes #9610
This commit is contained in:
parent
75670e4573
commit
2437fac013
7 changed files with 101 additions and 55 deletions
|
|
@ -31,8 +31,9 @@
|
|||
#include "urldata.h"
|
||||
#include "sendf.h"
|
||||
|
||||
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
|
||||
!defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
|
||||
#if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \
|
||||
!defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_IMAP))
|
||||
|
||||
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
|
||||
#include <libgen.h>
|
||||
|
|
@ -1924,8 +1925,8 @@ void Curl_mime_unpause(curl_mimepart *part)
|
|||
}
|
||||
|
||||
|
||||
#else /* !CURL_DISABLE_HTTP && !CURL_DISABLE_MIME ||
|
||||
!CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP */
|
||||
#else /* !CURL_DISABLE_MIME && (!CURL_DISABLE_HTTP ||
|
||||
!CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP) */
|
||||
|
||||
/* Mime not compiled in: define stubs for externally-referenced functions. */
|
||||
curl_mime *curl_mime_init(CURL *easy)
|
||||
|
|
|
|||
|
|
@ -134,8 +134,9 @@ struct curl_mimepart {
|
|||
|
||||
CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
|
||||
|
||||
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
|
||||
!defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
|
||||
#if !defined(CURL_DISABLE_MIME) && (!defined(CURL_DISABLE_HTTP) || \
|
||||
!defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_IMAP))
|
||||
|
||||
/* Prototypes. */
|
||||
void Curl_mime_initpart(struct curl_mimepart *part, struct Curl_easy *easy);
|
||||
|
|
|
|||
58
lib/setopt.c
58
lib/setopt.c
|
|
@ -654,6 +654,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
data->set.upload = FALSE;
|
||||
break;
|
||||
|
||||
#ifndef CURL_DISABLE_MIME
|
||||
case CURLOPT_HTTPPOST:
|
||||
/*
|
||||
* Set to make us do HTTP POST
|
||||
|
|
@ -662,6 +663,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
data->set.method = HTTPREQ_POST_FORM;
|
||||
data->set.opt_no_body = FALSE; /* this is implied */
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CURLOPT_AWS_SIGV4:
|
||||
/*
|
||||
|
|
@ -677,18 +679,6 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
data->set.httpauth = CURLAUTH_AWS_SIGV4;
|
||||
break;
|
||||
|
||||
case CURLOPT_MIMEPOST:
|
||||
/*
|
||||
* Set to make us do MIME/form POST
|
||||
*/
|
||||
result = Curl_mime_set_subparts(&data->set.mimepost,
|
||||
va_arg(param, curl_mime *), FALSE);
|
||||
if(!result) {
|
||||
data->set.method = HTTPREQ_POST_MIME;
|
||||
data->set.opt_no_body = FALSE; /* this is implied */
|
||||
}
|
||||
break;
|
||||
|
||||
case CURLOPT_REFERER:
|
||||
/*
|
||||
* String to set in the HTTP Referer: field.
|
||||
|
|
@ -710,13 +700,6 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
va_arg(param, char *));
|
||||
break;
|
||||
|
||||
case CURLOPT_HTTPHEADER:
|
||||
/*
|
||||
* Set a list with HTTP headers to use (or replace internals with)
|
||||
*/
|
||||
data->set.headers = va_arg(param, struct curl_slist *);
|
||||
break;
|
||||
|
||||
#ifndef CURL_DISABLE_PROXY
|
||||
case CURLOPT_PROXYHEADER:
|
||||
/*
|
||||
|
|
@ -954,6 +937,36 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
break;
|
||||
#endif /* CURL_DISABLE_HTTP */
|
||||
|
||||
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
|
||||
!defined(CURL_DISABLE_IMAP)
|
||||
# if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MIME)
|
||||
case CURLOPT_HTTPHEADER:
|
||||
/*
|
||||
* Set a list with HTTP headers to use (or replace internals with)
|
||||
*/
|
||||
data->set.headers = va_arg(param, struct curl_slist *);
|
||||
break;
|
||||
# endif
|
||||
|
||||
# ifndef CURL_DISABLE_MIME
|
||||
case CURLOPT_MIMEPOST:
|
||||
/*
|
||||
* Set to make us do MIME POST
|
||||
*/
|
||||
result = Curl_mime_set_subparts(&data->set.mimepost,
|
||||
va_arg(param, curl_mime *), FALSE);
|
||||
if(!result) {
|
||||
data->set.method = HTTPREQ_POST_MIME;
|
||||
data->set.opt_no_body = FALSE; /* this is implied */
|
||||
}
|
||||
break;
|
||||
|
||||
case CURLOPT_MIME_OPTIONS:
|
||||
data->set.mime_options = (unsigned int)va_arg(param, long);
|
||||
break;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
case CURLOPT_HTTPAUTH:
|
||||
/*
|
||||
* Set HTTP Authentication type BITMASK.
|
||||
|
|
@ -2659,13 +2672,6 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
|
||||
!defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
|
||||
case CURLOPT_MIME_OPTIONS:
|
||||
data->set.mime_options = (unsigned int)va_arg(param, long);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CURLOPT_SASL_AUTHZID:
|
||||
/* Authorization identity (identity to act as) */
|
||||
result = Curl_setstropt(&data->set.str[STRING_SASL_AUTHZID],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue