mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 06:15:13 +00:00
refactor: consolidate file path validation patterns and support scoped packages
- Extract file path validation regex into ValidationPatterns::FILE_PATH_PATTERN constant - Add filePathRules() and filePathMessages() helper methods for reusable validation - Extend allowed characters from [a-zA-Z0-9._\-/] to [a-zA-Z0-9._\-/~@+] to support: - Scoped npm packages (@org/package) - Language-specific directories (c++, rust+) - Version markers (v1~, build~) - Replace duplicate inline regex patterns across multiple files - Add tests for paths with @ symbol and tilde/plus characters
This commit is contained in:
1 parent
709e5e882e
commit
01031fc5f3
8 files changed
+74
-16
No files matched your search
@@ -3929,7 +3929,7 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
|
||||
|
||||
private function validatePathField(string $value, string $fieldName): string
|
||||
{
|
||||
if (! preg_match('/^\/[a-zA-Z0-9._\-\/]+$/', $value)) {
|
||||
if (! preg_match(\App\Support\ValidationPatterns::FILE_PATH_PATTERN, $value)) {
|
||||
throw new \RuntimeException("Invalid {$fieldName}: contains forbidden characters.");
|
||||
}
|
||||
if (str_contains($value, '..')) {
|
||||
|
||||
Reference in new issue
Block a user