Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yireo/Yireo_NextGenImages
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Dec 4, 2024
2 parents c038f68 + f746ccd commit 55007bf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Util/UrlConvertor.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,28 @@ public function isLocal(string $url): bool
public function getUrlFromFilename(string $filename): string
{
try {
if (strpos($filename, $this->getMediaFolder()) !== false) {
return str_replace($this->getMediaFolder() . '/', $this->getMediaUrl(), $filename);
$mediaFolder = $this->getMediaFolder();
$realMediaFolder = realpath($mediaFolder);
if (str_contains($filename, $realMediaFolder)) {
return str_replace($mediaFolder . '/', $this->getMediaUrl(), $filename);
}
} catch (FileSystemException|NoSuchEntityException $e) {
throw new NotFoundException((string)__('Media folder does not exist'));
}

try {
if (strpos($filename, $this->getStaticFolder()) !== false) {
$staticFolder = $this->getStaticFolder();
$realStaticFolder = realpath($staticFolder);
if (str_contains($filename, $realStaticFolder)) {
return str_replace($this->getStaticFolder() . '/', $this->getStaticUrl(), $filename);
}
} catch (FileSystemException|NoSuchEntityException $e) {
throw new NotFoundException((string)__('Static folder does not exist'));
}

if (strpos($filename, $this->getBaseFolder()) !== false) {
$baseFolder = $this->getBaseFolder();
$realBaseFolder = realpath($baseFolder);
if (str_contains($filename, $realBaseFolder)) {
return str_replace($this->getBaseFolder() . '/', $this->getBaseUrl(), $filename);
}

Expand Down

0 comments on commit 55007bf

Please sign in to comment.