Completed
Push — feature-20rc1 ( 008ae2 )
by Rob
16:55
created

FileSystemInsecureLocator::generateAbsolutePath()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
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\Imagine\Data\Loader\Locator;
13
14
class FileSystemInsecureLocator extends FileSystemLocator
15
{
16
    /**
17
     * @param string $root
18
     * @param string $path
19
     *
20
     * @return string|null
21
     */
22
    protected function generateAbsolutePath(string $root, string $path): ?string
23
    {
24
        if (false === mb_strpos($path, '..'.DIRECTORY_SEPARATOR) &&
25
            false === mb_strpos($path, DIRECTORY_SEPARATOR.'..') &&
26
            false !== file_exists($absolute = $root.DIRECTORY_SEPARATOR.$path)
27
        ) {
28
            return $absolute;
29
        }
30
31
        return null;
32
    }
33
}
34