Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console-core / src / functions.php
index 044a703185942dbf7c498d9b6e566b2de4973338..fc44e158a54e47e800d85a270aee64a52067b643 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Webmozart\PathUtil\Path;
+
 /**
  * @param string $path
  * @return null|string
@@ -10,27 +12,13 @@ function calculateRealPath($path)
         return null;
     }
 
-    if (realpath($path)) {
+    if (strpos($path, 'phar://')===0) {
         return $path;
     }
 
-    return transformToRealPath($path);
-}
-
-/**
- * @param $path
- * @return string
- */
-function transformToRealPath($path)
-{
-    if (strpos($path, '~') === 0) {
-        $home = rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/');
-        $path = preg_replace('/~/', $home, $path, 1);
-    }
-
-    if (!(strpos($path, '/') === 0)) {
-        $path = sprintf('%s/%s', getcwd(), $path);
+    if (realpath($path)) {
+        return $path;
     }
 
-    return realpath($path);
+    return Path::canonicalize($path);
 }