| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.4746 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 1 | public function assetExists($path) |
|
| 20 | { |
||
| 21 | 1 | $publicRoot = realpath($this->projectpath.'/public/').DIRECTORY_SEPARATOR; |
|
| 22 | 1 | $toCheck = $publicRoot.$path; |
|
| 23 | |||
| 24 | // check if the file exists |
||
| 25 | 1 | if (!is_file($toCheck)) { |
|
| 26 | 1 | return false; |
|
| 27 | } |
||
| 28 | |||
| 29 | // check if file is well contained in web/ directory (prevents ../ in paths) |
||
| 30 | if (0 !== strncmp($publicRoot, $toCheck, strlen($publicRoot))) { |
||
| 31 | return false; |
||
| 32 | } |
||
| 33 | |||
| 34 | return true; |
||
| 35 | } |
||
| 37 |