Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion main/rfc1867.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
int boundary_len = 0, cancel_upload = 0, is_arr_upload = 0;
size_t array_len = 0;
int64_t total_bytes = 0, max_file_size = 0;
int skip_upload = 0, anonymous_index = 0;
int anonymous_index = 0;
multipart_buffer *mbuff;
zval *array_ptr = (zval *) arg;
bool throw_exceptions = SG(request_parse_body_context).throw_exceptions;
Expand Down Expand Up @@ -822,6 +822,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
char *cd = NULL, *param = NULL, *filename = NULL, *tmp = NULL;
size_t blen = 0, wlen = 0;
zend_off_t offset;
int skip_upload = 0;

zend_llist_clean(&header);

Expand Down
39 changes: 39 additions & 0 deletions tests/basic/rfc1867_malformed_bracket_skip_upload.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
rfc1867: malformed bracket in one file part name does not skip subsequent valid file uploads
--INI--
file_uploads=1
--POST_RAW--
Content-Type: multipart/form-data; boundary=----PhpTestBoundaryH8
------PhpTestBoundaryH8
Content-Disposition: form-data; name="bad["; filename="bad.txt"
Content-Type: text/plain

bad-body
------PhpTestBoundaryH8
Content-Disposition: form-data; name="good"; filename="good.txt"
Content-Type: text/plain

good-body
------PhpTestBoundaryH8
Content-Disposition: form-data; name="field_after"

ok
------PhpTestBoundaryH8--
--FILE--
<?php
var_dump(array_keys($_POST));
var_dump(array_keys($_FILES));
var_dump($_FILES['good']['name'] ?? null);
var_dump($_FILES['good']['size'] ?? null);
?>
--EXPECT--
array(1) {
[0]=>
string(11) "field_after"
}
array(1) {
[0]=>
string(4) "good"
}
string(8) "good.txt"
int(9)
Loading