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

Method isPathWithinRoot

src/FileRise/Domain/UploadModel.php:157–169  ·  view source on GitHub ↗
(string $path, string $root)

Source from the content-addressed store, hash-verified

155 }
156
157 private static function isPathWithinRoot(string $path, string $root): bool
158 {
159 $rootReal = realpath($root);
160 $pathReal = realpath($path);
161 if ($rootReal === false || $pathReal === false) {
162 return false;
163 }
164
165 $rootNorm = rtrim(str_replace('\\', '/', $rootReal), '/') . '/';
166 $pathNorm = rtrim(str_replace('\\', '/', $pathReal), '/') . '/';
167
168 return strpos($pathNorm, $rootNorm) === 0;
169 }
170
171 private static function isTargetPathWithinDir(string $targetPath, string $targetDir): bool
172 {

Callers 2

handleUploadMethod · 0.95
removeChunksMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected