Skip to content

Commit 65e7e47

Browse files
committed
fix missing parentheses in filename* parsing
1 parent 7fccb0d commit 65e7e47

File tree

2 files changed

+55
-7
lines changed

2 files changed

+55
-7
lines changed

src/request_body_processor/multipart.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int Multipart::parse_content_disposition(const char *c_d_value, int offset) {
341341
const char* start_of_filename = p;
342342
while ((*p != '\0') && (*p != ';')) {
343343
if (*p == '%') {
344-
if ((*(p+1) == '\0') || (!isxdigit(*(p+1))) || (!isxdigit(*p+2))) {
344+
if ((*(p+1) == '\0') || (!isxdigit(*(p+1))) || (!isxdigit(*(p+2)))) {
345345
return -18;
346346
}
347347
p += 3;

test/test-cases/regression/issue-1825.json

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"enabled":1,
44
"version_min":300000,
5-
"title":"multipart Content-Disposition should allow filename* field (1/6)",
5+
"title":"multipart Content-Disposition should allow filename* field (1/7)",
66
"client":{
77
"ip":"200.249.12.31",
88
"port":123
@@ -50,7 +50,7 @@
5050
{
5151
"enabled":1,
5252
"version_min":300000,
53-
"title":"multipart Content-Disposition should allow filename* field (2/6)",
53+
"title":"multipart Content-Disposition should allow filename* field (2/7)",
5454
"client":{
5555
"ip":"200.249.12.31",
5656
"port":123
@@ -98,7 +98,7 @@
9898
{
9999
"enabled":1,
100100
"version_min":300000,
101-
"title":"multipart Content-Disposition should allow filename* field (3/6)",
101+
"title":"multipart Content-Disposition should allow filename* field (3/7)",
102102
"client":{
103103
"ip":"200.249.12.31",
104104
"port":123
@@ -146,7 +146,7 @@
146146
{
147147
"enabled":1,
148148
"version_min":300000,
149-
"title":"multipart Content-Disposition should allow filename* field (4/6)",
149+
"title":"multipart Content-Disposition should allow filename* field (4/7)",
150150
"client":{
151151
"ip":"200.249.12.31",
152152
"port":123
@@ -194,7 +194,7 @@
194194
{
195195
"enabled":1,
196196
"version_min":300000,
197-
"title":"multipart Content-Disposition should allow filename* field (5/6)",
197+
"title":"multipart Content-Disposition should allow filename* field (5/7)",
198198
"client":{
199199
"ip":"200.249.12.31",
200200
"port":123
@@ -242,7 +242,7 @@
242242
{
243243
"enabled":1,
244244
"version_min":300000,
245-
"title":"multipart Content-Disposition should allow filename* field (6/6)",
245+
"title":"multipart Content-Disposition should allow filename* field (6/7)",
246246
"client":{
247247
"ip":"200.249.12.31",
248248
"port":123
@@ -286,6 +286,54 @@
286286
"SecRuleEngine On",
287287
"SecRule MULTIPART_FILENAME \"@contains 0\" \"id:1,phase:2,pass,t:trim\""
288288
]
289+
},
290+
{
291+
"enabled":1,
292+
"version_min":300000,
293+
"title":"multipart Content-Disposition should allow filename* field (7/7)",
294+
"client":{
295+
"ip":"200.249.12.31",
296+
"port":123
297+
},
298+
"server":{
299+
"ip":"200.249.12.31",
300+
"port":80
301+
},
302+
"request":{
303+
"headers":{
304+
"Host":"localhost",
305+
"User-Agent":"curl/7.38.0",
306+
"Accept":"*/*",
307+
"Content-Length":"330",
308+
"Content-Type":"multipart/form-data; boundary=--------------------------756b6d74fa1a8ee2",
309+
"Expect":"100-continue"
310+
},
311+
"uri":"/",
312+
"method":"POST",
313+
"body":[
314+
"----------------------------756b6d74fa1a8ee2",
315+
"Content-Disposition: form-data; name=\"name\"",
316+
"",
317+
"test",
318+
"----------------------------756b6d74fa1a8ee2",
319+
"Content-Disposition: form-data; name=\"filedata\"; filename=\"03CB1664.txt\"; filename*=utf-8''%61%62.txt",
320+
"Content-Type: text/plain",
321+
"",
322+
"This is a very small test file..",
323+
"----------------------------756b6d74fa1a8ee2--"
324+
]
325+
},
326+
"response":{
327+
"headers":"",
328+
"body":""
329+
},
330+
"expected":{
331+
"http_code":200
332+
},
333+
"rules":[
334+
"SecRuleEngine On",
335+
"SecRule REQBODY_ERROR \"!@eq 0\" \"id:1,phase:2,deny,status:403\""
336+
]
289337
}
290338
]
291339

0 commit comments

Comments
 (0)