Skip to content

Commit 0a38d8e

Browse files
committed
:octocat: File::reaplath(): check for symlink
1 parent 33ef37f commit 0a38d8e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/File.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
use function file_get_contents;
2020
use function file_put_contents;
2121
use function is_file;
22+
use function is_link;
2223
use function is_readable;
2324
use function is_writable;
25+
use function readlink;
2426
use function realpath;
2527
use function unlink;
2628

@@ -62,10 +64,15 @@ public static function isWritable(string $file):bool{
6264
* @codeCoverageIgnore
6365
*/
6466
public static function realpath(string $path):string{
67+
68+
if(is_link($path)){
69+
$path = readlink($path);
70+
}
71+
6572
$realpath = realpath($path);
6673

6774
if($realpath === false){
68-
throw new InvalidArgumentException('invalid file path');
75+
throw new InvalidArgumentException('invalid path');
6976
}
7077

7178
return $realpath;

0 commit comments

Comments
 (0)