1
0
Fork 0

Fix Filesystem::isLocalPath including windows checks on linux

2.2
Jordi Boggiano 2024-05-29 13:42:12 +02:00
parent 7a1e02d1a3
commit 406e3f9ede
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 7 additions and 1 deletions

View File

@ -628,9 +628,15 @@ class Filesystem
*/
public static function isLocalPath($path)
{
// on windows, \\foo indicates network paths so we exclude those from local paths, however it is unsafe
// on linux as file:////foo (which would be a network path \\foo on windows) will resolve to /foo which could be a local path
if (Platform::isWindows()) {
return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
}
return Preg::isMatch('{^(file://|/|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
}
/**
* @param string $path
*