(string $path, string $root)
| 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 | { |
no outgoing calls
no test coverage detected