Skip to content

Commit

Permalink
Use realpath() to find the parent of a relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Feb 15, 2019
1 parent 8a7886c commit b8a0577
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ private function shiftPathUp($path)
{
$parent = dirname($path);

// If $path did not contain any parents, it may be a relative path:
// normalize it to the realpath first.
if ($parent === '.' && ($realpath = realpath($path))) {
$parent = dirname($realpath);
}

return in_array($parent, ['.', $path]) ? false : $parent;
}

Expand Down

0 comments on commit b8a0577

Please sign in to comment.