mirror of
https://github.com/composer/composer
synced 2025-05-09 16:42:57 +00:00
Fix Filesystem::isLocalPath including windows checks on linux
This commit is contained in:
parent
f38df849c2
commit
3c37a67c0c
1 changed files with 7 additions and 1 deletions
|
@ -638,7 +638,13 @@ class Filesystem
|
|||
*/
|
||||
public static function isLocalPath(string $path)
|
||||
{
|
||||
return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue