Completed
Push — 2.0 ( be4733...f3e24c )
by Rob
12:05
created

FileSystemInsecureLocator::generateAbsolutePath()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 2
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
            false !== strpos($path, DIRECTORY_SEPARATOR.'..') ||
26
            false === file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path)) {
27
            return false;
28
        }
29
30
        return $absolute;
31
    }
32
}
33