Browse Source

Alternative to mg_upload (Step 33/?)

bel 9 năm trước cách đây
mục cha
commit
665e5e9225
1 tập tin đã thay đổi với 6 bổ sung6 xóa
  1. 6 6
      src/handle_form.inl

+ 6 - 6
src/handle_form.inl

@@ -509,10 +509,10 @@ mg_handle_form_data(struct mg_connection *conn,
 			                                      sizeof(path) - 1,
 			                                      fdh);
 
-			next = strstr(hbuf, "--");
-			while (next && (strncmp(next + 2, boundary, bl))) {
+			next = strstr(hbuf, "\r\n--");
+			while (next && (strncmp(next + 4, boundary, bl))) {
 				/* found "--" not followed by boundary: look for next "--" */
-				next = strstr(next + 1, "--");
+				next = strstr(next + 1, "\r\n--");
 			}
 
 			if (disposition == FORM_DISPOSITION_GET) {
@@ -527,8 +527,8 @@ mg_handle_form_data(struct mg_connection *conn,
 				                      (size_t)(nend - nbeg),
 				                      fbeg,
 				                      (size_t)(fend - fbeg),
-				                      hend,
-				                      (size_t)(next - hend),
+				                      hend + 4,
+				                      (size_t)(next - hend - 4),
 				                      fdh);
 			}
 
@@ -550,7 +550,7 @@ mg_handle_form_data(struct mg_connection *conn,
 			}
 
 			/* Remove from the buffer */
-			used = next - buf;
+			used = next - buf + 2;
 			memmove(buf, buf + (size_t)used, sizeof(buf) - (size_t)used);
 			buf_fill -= used;