Skip to content

Commit fbea731

Browse files
martinhsvzimmerle
authored andcommitted
Fix: FILES variable does not use multipart part name for key
1 parent f1f2527 commit fbea731

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.x.y - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Fix: FILES variable does not use multipart part name for key
5+
[Issue #2377 - @martinhsv]
46
- Replaces put with setenv in SetEnv action
57
[Issue #2469 - @martinhsv, @WGH-, @zimmerle]
68
- Regression: Mark the test as failed in case of segfault.

src/request_body_processor/multipart.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ int Multipart::multipart_complete(std::string *error) {
11381138
name.assign(m->m_filename);
11391139
}
11401140

1141-
m_transaction->m_variableFiles.set(m->m_filename,
1141+
m_transaction->m_variableFiles.set(m->m_name,
11421142
m->m_filename, m->m_filenameOffset);
11431143

11441144
m_transaction->m_variableFilesNames.set(m->m_name,

test/test-cases/regression/variable-FILES.json

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"enabled":1,
44
"version_min":300000,
5-
"title":"Testing Variables :: FILES (1/1)",
5+
"title":"Testing Variables :: FILES (1/2)",
66
"client":{
77
"ip":"200.249.12.31",
88
"port":123
@@ -57,5 +57,64 @@
5757
"SecRuleEngine On",
5858
"SecRule FILES \"@contains small_text_file.txt\" \"id:1,phase:3,pass,t:trim\""
5959
]
60+
},
61+
{
62+
"enabled":1,
63+
"version_min":300000,
64+
"title":"Testing Variables :: FILES (2/2)",
65+
"client":{
66+
"ip":"200.249.12.31",
67+
"port":123
68+
},
69+
"server":{
70+
"ip":"200.249.12.31",
71+
"port":80
72+
},
73+
"request":{
74+
"headers":{
75+
"Host":"localhost",
76+
"User-Agent":"curl/7.38.0",
77+
"Accept":"*/*",
78+
"Content-Length":"330",
79+
"Content-Type":"multipart/form-data; boundary=--------------------------756b6d74fa1a8ee2",
80+
"Expect":"100-continue"
81+
},
82+
"uri":"/",
83+
"method":"POST",
84+
"body":[
85+
"----------------------------756b6d74fa1a8ee2",
86+
"Content-Disposition: form-data; name=\"name\"",
87+
"",
88+
"test",
89+
"----------------------------756b6d74fa1a8ee2",
90+
"Content-Disposition: form-data; name=\"filedata1\"; filename=\"myfile.txt\"",
91+
"Content-Type: text/plain",
92+
"",
93+
"This is a very small test file..",
94+
"----------------------------756b6d74fa1a8ee2",
95+
"Content-Disposition: form-data; name=\"filedata2\"; filename=\"nextfile.txt\"",
96+
"Content-Type: text/plain",
97+
"",
98+
"This is another very small test file..",
99+
"----------------------------756b6d74fa1a8ee2--"
100+
]
101+
},
102+
"response":{
103+
"headers":{
104+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
105+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
106+
"Content-Type":"text/html"
107+
},
108+
"body":[
109+
"no need."
110+
]
111+
},
112+
"expected":{
113+
"http_code": 403
114+
},
115+
"rules":[
116+
"SecRuleEngine On",
117+
"SecRule FILES:filedata1 \"@contains myfile.txt\" \"id:1,phase:2,deny,status:403\""
118+
]
60119
}
61120
]

0 commit comments

Comments
 (0)