| Conditions | 6 |
| Paths | 4 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 118 | protected function validateFileNamePath($filename) |
|
| 26 | { |
||
| 27 | 118 | $filename = StringBuilder::stringReplace("\0", '', $filename); // (ASCII 0 (0x00)) |
|
| 28 | 118 | $filename = realpath($filename); // Path traversal escape and absolute path fetching |
|
| 29 | |||
| 30 | // Clear path cache |
||
| 31 | 118 | if (!empty($filename)) { |
|
| 32 | 50 | clearstatcache(true, $filename); |
|
| 33 | } |
||
| 34 | |||
| 35 | // Check if path is valid and the file is readable |
||
| 36 | 118 | if ($filename === false || !file_exists($filename) || !is_readable($filename) || !is_file($filename)) { |
|
| 37 | 68 | throw new \RuntimeException('File is not found or can not be accessed.'); |
|
| 38 | } |
||
| 41 |