Skip to content

Commit 72cf701

Browse files
committed
Add path verification to Mediagallery uploader plugin
1 parent 32ed03c commit 72cf701

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ public function __construct(
8585
*/
8686
public function afterSave(Uploader $subject, array $result): array
8787
{
88-
if (!$this->config->isEnabled()) {
88+
$mediaFolder = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath();
89+
90+
if (!$this->config->isEnabled() || substr($result['path'], 0, strlen($mediaFolder)) !== $mediaFolder) {
8991
return $result;
9092
}
9193

9294
$path = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)
9395
->getRelativePath(rtrim($result['path'], '/') . '/' . ltrim($result['file'], '/'));
96+
9497
if (!$this->isApplicable($path)) {
9598
return $result;
9699
}

0 commit comments

Comments
 (0)