(string $folder)
| 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]. |
no test coverage detected