Fix the resolution of the path on Windows
authorAlexander Ebert <ebert@woltlab.com>
Fri, 25 Oct 2024 09:24:34 +0000 (11:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 25 Oct 2024 09:24:34 +0000 (11:24 +0200)
See https://www.woltlab.com/community/thread/309045/

wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php

index 590beafc0f351e022df94f028e659304086337cc..90c163df172d0877356113b6c291d2c4dcccfdaf 100644 (file)
@@ -140,8 +140,14 @@ class UploadFile
 
         if ($this->processed) {
             if ($this->imageLink === null) {
-                // try to guess path
-                $link = \str_replace(WCF_DIR, WCF::getPath(), $this->location);
+                $corePath = FileUtil::unifyDirSeparator(\WCF_DIR);
+                $location = FileUtil::unifyDirSeparator($this->location);
+
+                if (\str_starts_with($location, $corePath)) {
+                    $link = WCF::getPath() . \mb_substr($location, \mb_strlen($corePath));
+                } else {
+                    $link = $location;
+                }
             } else {
                 $link = $this->imageLink;
             }