You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 067bc71
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/changelogs/v4.7.7.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,16 @@ Release Date: Unreleased
8
8
9
9
## Message Changes
10
10
11
+
- Added the `HTTP.invalidFileName` language string.
12
+
11
13
## Changes
12
14
13
15
## Deprecations
14
16
15
17
## Bugs Fixed
16
18
17
19
-**Database:** Fixed a bug where `SQLSRV\Forge::_alterTable()` interpolated table and column names without escaping in default constraint lookups.
20
+
-**HTTP:** Fixed a bug where `UploadedFile::move()` and `UploadedFile::store()` on Windows could store a file under a different name than `getName()` reported, or write its contents to an NTFS alternate data stream. Filenames ending in a period or space or containing a colon are now rejected, including explicitly supplied names.
18
21
-**Security:** Fixed a bug where `Security::__construct()` threw a `TypeError` when the CSRF cookie was an array, causing an HTTP 500 response for affected requests.
19
22
-**Worker Mode:** Fixed a bug where every request that ended with an uncaught exception, including a `404 Page Not Found` without a 404 override, called `exit()` in the exception handler. This ended the worker script, so FrankenPHP booted a new one, and the worker loop skipped its cleanup after the request. The exception handler now returns to the worker loop.
Copy file name to clipboardExpand all lines: docs/libraries/uploaded_files.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -448,6 +448,7 @@ echo $clientPath; // dir/file.txt, or dir/sub_dir/file.txt
448
448
Do not let user input directly decide the destination directory. The `$targetPath` argument of `move()` and the `$folderName` argument of `store()` are never sanitized, so an attacker-controlled value containing `../` can move the uploaded file outside the intended directory. Use directories controlled by your application.
449
449
450
450
Filenames are only sanitized by default: `move()` sanitizes the client-provided name when the `$name` argument is omitted, and `store()` generates a random name when `$fileName` is omitted. A caller-supplied `$name` or `$fileName` is NOT sanitized, so if you pass one, generate it yourself or sanitize it with `sanitize_filename`.
451
+
On Windows, `move()` and `store()` reject names ending in a period or space or containing a colon, whether the name was supplied by the caller or chosen by default. Sanitization alone does not remove these forms. Use a generated name when possible.
451
452
452
453
Sanitizing a client-provided filename does not make it safe to keep in a web-accessible directory where scripts can execute. Some web servers select a handler from any extension in a filename, including an extension before the final one. Keep uploads outside the public directory with `store()` when possible. If they must be public, disable script execution in the upload directory and pass `$file->getRandomName()` as the second argument to `move()`.
453
454
@@ -461,7 +462,7 @@ Each file can be moved to its new location with the aptly named `move()` method.
461
462
$file->move(WRITEPATH . 'uploads');
462
463
```
463
464
464
-
By default, the client-provided filename is sanitized and used.
465
+
By default, the client-provided filename is sanitized and used. On Windows, an `HTTPException` is thrown if the name to be stored ends with a period or a space, or contains a colon. This also applies when you pass a name explicitly. Such names may be stored under a different filename or in an NTFS alternate data stream. Use a generated filename if the client-provided name is rejected.
465
466
466
467
#### with New Filename
467
468
@@ -504,6 +505,7 @@ Moving an uploaded file can fail, with an `HTTPException`, under several circums
504
505
505
506
- the file has already been moved
506
507
- the file did not upload successfully
508
+
- on Windows, the filename ends with a period or a space, or contains a colon
507
509
- the file move operation fails (e.g., improper permissions)
508
510
509
511
### Store Files
@@ -536,4 +538,5 @@ Moving an uploaded file can fail, with an `HTTPException`, under several circums
536
538
537
539
- the file has already been moved
538
540
- the file did not upload successfully
541
+
- on Windows, the supplied filename ends with a period or a space, or contains a colon
539
542
- the file move operation fails (e.g., improper permissions)
0 commit comments