Completed
Push — 1.0 ( 657f08...d94044 )
by Rob
09:07
created

FileSystemInsecureLocator::generateAbsolutePath()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 4
nc 3
nop 2
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Binary\Locator;
13
14
class FileSystemInsecureLocator extends FileSystemLocator
15
{
16
    /**
17
     * @param string $root
18
     * @param string $path
19
     *
20
     * @return string|false
21
     */
22
    protected function generateAbsolutePath($root, $path)
23
    {
24
        if (false !== strpos($path, '..'.DIRECTORY_SEPARATOR)) {
25
            return false;
26
        }
27
28
        return file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path) ? $absolute : false;
29
    }
30
}
31