Skip to content

Commit 7cf0445

Browse files
authored
Merge pull request #2870 from airween/v3/multipartpartheaderfix
Set correct line end in case of `MULTIPART_PART_HEADER` variable
2 parents a830ef6 + 6623c0a commit 7cf0445

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

Diff for: src/request_body_processor/multipart.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ int Multipart::process_part_header(std::string *error, int offset) {
935935
"Multipart: Added part header \"" + header_name \
936936
+ "\" \"" + header_value + "\".");
937937
if (len_without_termination > 0) {
938-
m_mpp->m_last_header_line.assign(m_buf);
938+
m_mpp->m_last_header_line.assign(m_buf, len_without_termination);
939939
} else {
940940
m_mpp->m_last_header_line.assign("");
941941
}

Diff for: test/test-cases/regression/variable-MULTIPART_PART_HEADERS.json

+51
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,57 @@
162162
"SecRuleEngine On",
163163
"SecRule MULTIPART_PART_HEADERS:parm2 \"@rx content-type:.*jpeg\" \"phase:2,deny,status:403,id:500074,t:lowercase\""
164164
]
165+
},
166+
{
167+
"enabled":1,
168+
"version_min":300000,
169+
"title":"Testing Variables :: MULTIPART_PART_HEADERS (check EOL)",
170+
"client":{
171+
"ip":"200.249.12.31",
172+
"port":123
173+
},
174+
"server":{
175+
"ip":"200.249.12.31",
176+
"port":80
177+
},
178+
"request":{
179+
"headers":{
180+
"Host":"localhost",
181+
"User-Agent":"curl/7.38.0",
182+
"Accept":"*/*",
183+
"Content-Length":"249",
184+
"Content-Type":"multipart/form-data; boundary=-----------------------------69343412719991675451336310646",
185+
"Expect":"100-continue"
186+
},
187+
"uri":"/",
188+
"method":"POST",
189+
"body":[
190+
"-------------------------------69343412719991675451336310646",
191+
"Content-Disposition: form-data; name=\"file\"; filename=\"New Text Document.txt\"",
192+
"Content-Type: text/plain; charset=utf-8\r\n",
193+
"",
194+
"1",
195+
"-------------------------------69343412719991675451336310646--"
196+
]
197+
},
198+
"response":{
199+
"headers":{
200+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
201+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
202+
"Content-Type":"text/html"
203+
},
204+
"body":[
205+
"no need."
206+
]
207+
},
208+
"expected":{
209+
"http_code": 200
210+
},
211+
"rules":[
212+
"SecRuleEngine On",
213+
"SecRule MULTIPART_PART_HEADERS \"@rx ^content-type\\s*+:\\s*+(.*)$\" \"id:922110,phase:2,deny,capture,t:none,t:lowercase,chain\"",
214+
"SecRule TX:1 \"!@rx ^text/plain; charset=(?:iso-8859-15?|windows-1252|utf-8)$\" \"t:lowercase\""
215+
]
165216
}
166217
]
167218

0 commit comments

Comments
 (0)