REGEX_FOLDER_NAME updated (closes #39)
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Changes 5/26/2025
|
||||||
|
|
||||||
|
- Updated `REGEX_FOLDER_NAME` in `config.php` to forbids < > : " | ? * characters in folder names.
|
||||||
|
- Ensures the whole name can’t end in a space or period.
|
||||||
|
- Blocks Windows device names.
|
||||||
|
|
||||||
|
- Updated `FolderController.php` when `createFolder` issues invalid folder name to return `http_response_code(400);`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Changes 5/23/2025 v1.3.8
|
## Changes 5/23/2025 v1.3.8
|
||||||
|
|
||||||
- **Folder-strip context menu**
|
- **Folder-strip context menu**
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ define('TRASH_DIR', UPLOAD_DIR . 'trash/');
|
|||||||
define('TIMEZONE', 'America/New_York');
|
define('TIMEZONE', 'America/New_York');
|
||||||
define('DATE_TIME_FORMAT','m/d/y h:iA');
|
define('DATE_TIME_FORMAT','m/d/y h:iA');
|
||||||
define('TOTAL_UPLOAD_SIZE','5G');
|
define('TOTAL_UPLOAD_SIZE','5G');
|
||||||
define('REGEX_FOLDER_NAME', '/^[\p{L}\p{N}_\-\s\/\\\\]+$/u');
|
define('REGEX_FOLDER_NAME','/^(?!^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$)(?!.*[. ]$)(?:[^<>:"\/\\\\|?*\x00-\x1F]{1,255})(?:[\/\\\\][^<>:"\/\\\\|?*\x00-\x1F]{1,255})*$/xu');
|
||||||
define('PATTERN_FOLDER_NAME','[\p{L}\p{N}_\-\s\/\\\\]+');
|
define('PATTERN_FOLDER_NAME','[\p{L}\p{N}_\-\s\/\\\\]+');
|
||||||
define('REGEX_FILE_NAME', '/^[^\x00-\x1F\/\\\\]{1,255}$/u');
|
define('REGEX_FILE_NAME', '/^[^\x00-\x1F\/\\\\]{1,255}$/u');
|
||||||
define('REGEX_USER', '/^[\p{L}\p{N}_\- ]+$/u');
|
define('REGEX_USER', '/^[\p{L}\p{N}_\- ]+$/u');
|
||||||
|
|||||||
@@ -96,12 +96,14 @@ class FolderController
|
|||||||
|
|
||||||
// Basic sanitation for folderName.
|
// Basic sanitation for folderName.
|
||||||
if (!preg_match(REGEX_FOLDER_NAME, $folderName)) {
|
if (!preg_match(REGEX_FOLDER_NAME, $folderName)) {
|
||||||
|
http_response_code(400);
|
||||||
echo json_encode(['error' => 'Invalid folder name.']);
|
echo json_encode(['error' => 'Invalid folder name.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally sanitize the parent.
|
// Optionally sanitize the parent.
|
||||||
if ($parent && !preg_match(REGEX_FOLDER_NAME, $parent)) {
|
if ($parent && !preg_match(REGEX_FOLDER_NAME, $parent)) {
|
||||||
|
http_response_code(400);
|
||||||
echo json_encode(['error' => 'Invalid parent folder name.']);
|
echo json_encode(['error' => 'Invalid parent folder name.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user