Skip to content

Support for "filename*" in multipart (precedence over "filename") #2945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apache2/msc_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static char *multipart_construct_filename(modsec_rec *msr) {
*/
static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value) {
char *p = NULL, *t = NULL;
int filenamestar = 0;

/* accept only what we understand */
if (strncmp(c_d_value, "form-data", 9) != 0) {
Expand Down Expand Up @@ -210,6 +211,7 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)

validate_quotes(msr, value, quote);

if (filenamestar) continue;
msr->multipart_filename = apr_pstrdup(msr->mp, value);

if (msr->mpd->mpp->filename != NULL) {
Expand All @@ -224,6 +226,22 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)
log_escape_nq(msr->mp, value));
}
}
else if (strcmp(name, "filename*") == 0) {
if (strncasecmp(value, "UTF-8''", 7) && strncasecmp(value, "ISO-8859-1''", 12)) {
msr_log(msr, 4, "Multipart: filename* must contain encoding: %s",
log_escape_nq(msr->mp, value));
msr->mpd->flag_error = 1;
return -16;
}
filenamestar = 1;
value = strstr(value, "''") + 2;
msr->multipart_filename = apr_pstrdup(msr->mp, value);
msr->mpd->mpp->filename = value;
if (msr->txcfg->debuglog_level >= 9) {
msr_log(msr, 9, "Multipart: Content-Disposition filename*: %s",
log_escape_nq(msr->mp, value));
}
}
else return -11;

if (*p != '\0') {
Expand Down