MCPcopy Create free account
hub / github.com/error311/FileRise / sanitizeFolder

Method sanitizeFolder

src/FileRise/Domain/UploadModel.php:569–593  ·  view source on GitHub ↗
(string $folder)

Source from the content-addressed store, hash-verified

567 }
568
569 private static function sanitizeFolder(string $folder): string
570 {
571 // decode "%20", normalise slashes & trim via ACL helper
572 $f = ACL::normalizeFolder(rawurldecode($folder));
573
574 // model uses '' to represent root
575 if ($f === 'root') {
576 return '';
577 }
578
579 // forbid dot segments / empty parts
580 foreach (explode('/', $f) as $seg) {
581 if ($seg === '' || $seg === '.' || $seg === '..') {
582 return '';
583 }
584 }
585
586 // allow spaces & unicode via your global regex
587 // (REGEX_FOLDER_NAME validates a path "seg(/seg)*")
588 if (!preg_match(REGEX_FOLDER_NAME, $f)) {
589 return '';
590 }
591
592 return $f; // safe, normalised, with spaces allowed
593 }
594
595 /**
596 * Parse a resumable relative path into [subDir, fileName].

Callers 4

handleUploadMethod · 0.95
removeChunksMethod · 0.95
checkExistingMethod · 0.95

Calls 1

normalizeFolderMethod · 0.45

Tested by

no test coverage detected