Skip to content

Retain full path of files for directory uploads #6917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2021
Merged
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
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ string(%d) "rfc1867"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -67,9 +69,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_cleanup.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ string(%d) "rfc1867-cleanup"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -67,9 +69,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_disabled.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ session_destroy();
string(%d) "rfc1867-disabled"
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -60,9 +62,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_disabled_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ session_destroy();
string(%d) "rfc1867-disabled-2"
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -60,9 +62,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_inter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ session_destroy();
string(%d) "rfc1867-inter"
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -70,9 +72,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_no_name.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ session_destroy();
string(%d) "rfc1867-no-name"
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -60,9 +62,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_cookie.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ string(%d) "rfc1867-sid-cookie"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -66,9 +68,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_get.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ string(%d) "rfc1867-sid-get"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -64,9 +66,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_get_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ string(%d) "rfc1867-sid-get-2"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -66,9 +68,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_invalid.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ string(%d) ""
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -78,9 +80,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_only_cookie.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ string(%d) "rfc1867-sid-only-cookie"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -66,9 +68,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_only_cookie_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ string(%d) "%s"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -63,9 +65,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
8 changes: 6 additions & 2 deletions ext/session/tests/rfc1867_sid_post.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ string(%d) "rfc1867-sid-post"
bool(true)
array(2) {
["file1"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file1.txt"
["full_path"]=>
string(9) "file1.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand All @@ -62,9 +64,11 @@ array(2) {
int(1)
}
["file2"]=>
array(5) {
array(6) {
["name"]=>
string(9) "file2.txt"
["full_path"]=>
string(9) "file2.txt"
["type"]=>
string(0) ""
["tmp_name"]=>
Expand Down
15 changes: 13 additions & 2 deletions main/rfc1867.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ PHPAPI int (*php_rfc1867_callback)(unsigned int event, void *event_data, void **
static void safe_php_register_variable(char *var, char *strval, size_t val_len, zval *track_vars_array, bool override_protection);

/* The longest property name we use in an uploaded file array */
#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
#define MAX_SIZE_OF_INDEX sizeof("[full_path]")

/* The longest anonymous name */
#define MAX_SIZE_ANONNAME 33
Expand Down Expand Up @@ -1142,9 +1142,20 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
snprintf(lbuf, llen, "%s[name]", param);
}
register_http_post_files_variable(lbuf, s, &PG(http_globals)[TRACK_VARS_FILES], 0);
efree(filename);
s = NULL;

/* Add full path of supplied file for folder uploads via
* <input type="file" name="files" multiple webkitdirectory>
*/
/* Add $foo[full_path] */
if (is_arr_upload) {
snprintf(lbuf, llen, "%s[full_path][%s]", abuf, array_index);
} else {
snprintf(lbuf, llen, "%s[full_path]", param);
}
register_http_post_files_variable(lbuf, filename, &PG(http_globals)[TRACK_VARS_FILES], 0);
efree(filename);

/* Possible Content-Type: */
if (cancel_upload || !(cd = php_mime_get_hdr_value(header, "Content-Type"))) {
cd = "";
Expand Down
4 changes: 3 additions & 1 deletion sapi/cli/tests/php_cli_server_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ Content-type: text/html; charset=UTF-8

array(1) {
["userfile"]=>
array(5) {
array(6) {
["name"]=>
string(12) "laruence.txt"
["full_path"]=>
string(12) "laruence.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
Expand Down
4 changes: 3 additions & 1 deletion tests/basic/021.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ var_dump($_POST);
--EXPECTF--
array(1) {
["pics"]=>
array(5) {
array(6) {
["name"]=>
string(12) "bug37276.txt"
["full_path"]=>
string(12) "bug37276.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
Expand Down
Loading