Skip to content

Commit

Permalink
FileHelper::resolveAbsolutePath() confuse directory of 2 characters…
Browse files Browse the repository at this point in the history
… with '..'
  • Loading branch information
ElGigi committed Mar 4, 2022
1 parent 6745fce commit 5999cae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This projec
to [Semantic Versioning] (http://semver.org/). For change log format,
use [Keep a Changelog] (http://keepachangelog.com/).

## [1.6.3] - 2022-03-04

### Fixed

- `FileHelper::resolveAbsolutePath()` confuse directory of 2 characters with '..'

## [1.6.2] - 2022-02-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function resolveAbsolutePath(string $srcPath, string $dstPath): ?s

// Replacement of '../'
do {
$finalPath = preg_replace('#(/|^)([^\\\/?%*:|"<>.]+)/..(/|$)#', '/', $finalPath, -1, $nbReplacements);
$finalPath = preg_replace('#(/|^)([^\\\/?%*:|"<>.]+)/\.\.(/|$)#', '/', $finalPath, -1, $nbReplacements);
} while ($nbReplacements > 0);
if (false === strpos($finalPath, './')) {
Expand Down
3 changes: 3 additions & 0 deletions tests/FileHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public function absolutePathProvider(): array
['foo/bar/', '../qux', '/foo/qux'],
['foo/bar/', '', '/foo/bar/'],
['foo/bar', '', '/foo/bar'],
['/foo/bar/', '/foo/bar.html', '/foo/bar.html'],
['/foo/bar/', '/foo/bar/baz/qux.html', '/foo/bar/baz/qux.html'],
['/foo/ba/', '/foo/ba/baz/qux.html', '/foo/ba/baz/qux.html'],
];
}

Expand Down

0 comments on commit 5999cae

Please sign in to comment.