Skip to content

A self-hosted media server and file management system

feat: normalise config storage path and block root folder use

aminnausin58569a66106f
diff --git a/app/Http/Requests/Server/UpdateStorageConfigRequest.php b/app/Http/Requests/Server/UpdateStorageConfigRequest.php
index 04ae0ddf..5f80c2a9 100644
--- a/app/Http/Requests/Server/UpdateStorageConfigRequest.php
+++ b/app/Http/Requests/Server/UpdateStorageConfigRequest.php
@@ -16,12 +16,21 @@ class UpdateStorageConfigRequest extends FormRequest {
}
protected function prepareForValidation() {
- if ($this->has('cache_path')) {
- $this->merge(['cache_path' => rtrim($this->cache_path, '/')]);
- }
+ $paths = ['cache_path', 'metadata_path'];
+
+ foreach ($paths as $path) {
+ if (! $this->has($path)) {
+ continue;
+ }
+
+ $value = str_replace('\\', '/', $this->input($path));
+ $value = rtrim($value, '/');
+
+ if ($value === '') {
+ $value = null;
+ }
- if ($this->has('metadata_path')) {
- $this->merge(['metadata_path' => rtrim($this->metadata_path, '/')]);
+ $this->merge([$path => $value]);
}
}
@@ -48,7 +57,7 @@ class UpdateStorageConfigRequest extends FormRequest {
* @return bool
*/
private function validatePath(string $path, Closure $fail) {
- if (! $path) {
+ if (empty($path)) {
return;
}
@@ -58,6 +67,12 @@ class UpdateStorageConfigRequest extends FormRequest {
return;
}
+ if ($path === 'storage') {
+ $fail('The root storage folder is not a valid selection.');
+
+ return;
+ }
+
$exists = str_starts_with($path, 'storage/')
? Storage::disk('local')->exists(Str::after($path, 'storage/'))
: is_dir($path);