Skip to content

Commit 2ce950f

Browse files
authored
Fix incorrect URL generation in getContentUrl() (#3759)
trim($this->root, '/') strips the leading slash from the root path, making strlen() return a value 1 less than expected. This causes substr() to include an extra character from the root folder name in the relative path. For example, with root folder "images": - Expected URL: /files/image.jpg - Actual URL: /files/s/image.jpg Using strlen($this->root) + 1 is consistent with other URL construction methods in elFinderVolumeLocalFileSystem (lines 206, 612, 845, 1420) which all use this correct pattern. Fixes #3746
1 parent ecdc053 commit 2ce950f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎php/elFinderVolumeDriver.class.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,7 +3331,7 @@ public function getContentUrl($hash, $options = array())
33313331
}
33323332
}
33333333
if (empty($file['url']) && $this->URL) {
3334-
$path = str_replace($this->separator, '/', substr($this->decode($hash), strlen(trim($this->root, '/' . $this->separator))));
3334+
$path = str_replace($this->separator, '/', substr($this->decode($hash), strlen($this->root) + 1));
33353335
if ($this->encoding) {
33363336
$path = $this->convEncIn($path, true);
33373337
}

0 commit comments

Comments
 (0)