1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vweb: split and parse Content-Type header correctly (#9756)

This commit is contained in:
Miccah
2021-04-16 00:46:06 -05:00
committed by GitHub
parent b11b744630
commit e2be3ec396
5 changed files with 37 additions and 5 deletions

View File

@@ -336,8 +336,9 @@ fn handle_conn<T>(mut conn net.TcpConn, mut app T) {
page_gen_start: page_gen_start
}
if req.method in vweb.methods_with_form {
if 'multipart/form-data' in req.header.values(.content_type) {
boundary := req.header.values(.content_type).filter(it.starts_with('boundary='))
ct := req.header.get(.content_type) or { '' }.split(';').map(it.trim_left(' \t'))
if 'multipart/form-data' in ct {
boundary := ct.filter(it.starts_with('boundary='))
if boundary.len != 1 {
send_string(mut conn, vweb.http_400) or {}
return