Prechádzať zdrojové kódy

Fix handle_form for quoted strings and reactivate unit test

bel2125 8 rokov pred
rodič
commit
9ec3c463f5
2 zmenil súbory, kde vykonal 4 pridanie a 11 odobranie
  1. 2 9
      src/handle_form.inl
  2. 2 2
      test/public_server.c

+ 2 - 9
src/handle_form.inl

@@ -543,12 +543,6 @@ mg_handle_form_request(struct mg_connection *conn,
 		/* Copy boundary string to variable "boundary" */
 		fbeg = content_type + bl + 9;
 		bl = strlen(fbeg);
-		if (*fbeg == '\"') {
-			/* RFC 2046 permits the boundary string to be quoted. */
-			/* If the boundary is quoted, trim the quotes */
-			fbeg++;
-			bl--;
-		}
 		boundary = mg_malloc(bl + 1);
 		if (!boundary) {
 			/* Out of memory */
@@ -561,10 +555,9 @@ mg_handle_form_request(struct mg_connection *conn,
 		memcpy(boundary, fbeg, bl);
 		boundary[bl] = 0;
 
-
-		/* Trim, if string is quoted */
+		/* RFC 2046 permits the boundary string to be quoted. */
+		/* If the boundary is quoted, trim the quotes */
 		if (boundary[0] == '"') {
-			/* RFC 2046 permits the boundary string to be quoted. */
 			hbuf = strchr(boundary + 1, '"');
 			if ((!hbuf) || (*hbuf != '"')) {
 				/* Malformed request */

+ 2 - 2
test/public_server.c

@@ -2631,7 +2631,7 @@ START_TEST(test_handle_form)
 	ck_assert(ri != NULL);
 	ck_assert_str_eq(ri->local_uri, "200");
 	mg_close_connection(client_conn);
-#if 0
+
 	/* Handle form: "POST multipart/form-data" with chunked transfer
 	 * encoding, using a quoted boundary string */
 	client_conn = mg_download(
@@ -2678,7 +2678,7 @@ START_TEST(test_handle_form)
 	ck_assert(ri != NULL);
 	ck_assert_str_eq(ri->local_uri, "200");
 	mg_close_connection(client_conn);
-#endif
+
 
 	/* Now test form_store */