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 76f2433
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,12 +8,15 @@ 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
19
+
-**HTTP:** Fixed a bug where `UploadedFile::move()` with the default filename on Windows could store a file under a different name than `getName()` reported, or write its contents to an NTFS alternate data stream. Client filenames ending in a period or space or containing a colon are now rejected in this case.
17
20
-**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.
18
21
-**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
+3-1Lines changed: 3 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, sanitizing a client-provided name does not remove trailing periods or spaces or prevent NTFS alternate data streams. Use a generated name if you need to pass an explicit filename.
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 sanitized name ends with a period or a space, or contains a colon. 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 `$name` argument is omitted and the sanitized client-provided filename ends with a period or a space, or contains a colon
507
509
- the file move operation fails (e.g., improper permissions)
0 commit comments