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 8277b44
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/changelogs/v4.7.7.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Release Date: Unreleased
16
16
17
17
## Bugs Fixed
18
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.
19
+
-**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.
20
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.
21
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
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -448,7 +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
+
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.
452
452
453
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()`.
454
454
@@ -462,7 +462,7 @@ Each file can be moved to its new location with the aptly named `move()` method.
462
462
$file->move(WRITEPATH . 'uploads');
463
463
```
464
464
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
+
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.
466
466
467
467
#### with New Filename
468
468
@@ -505,7 +505,7 @@ Moving an uploaded file can fail, with an `HTTPException`, under several circums
505
505
506
506
- the file has already been moved
507
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
508
+
- on Windows, the filename ends with a period or a space, or contains a colon
509
509
- the file move operation fails (e.g., improper permissions)
510
510
511
511
### Store Files
@@ -538,4 +538,5 @@ Moving an uploaded file can fail, with an `HTTPException`, under several circums
538
538
539
539
- the file has already been moved
540
540
- the file did not upload successfully
541
+
- on Windows, the supplied filename ends with a period or a space, or contains a colon
541
542
- the file move operation fails (e.g., improper permissions)
0 commit comments