Skip to content

Commit f11a438

Browse files
author
Hwashiang Yu
committed
MC-36640: Validation Update
- Fixed stoage upload file pathing for directories - Updated read directory exist logic
1 parent dfe8a07 commit f11a438

File tree

2 files changed

+9
-3
lines changed
  • app/code/Magento/Cms/Model/Wysiwyg/Images
  • lib/internal/Magento/Framework/Filesystem/Directory

2 files changed

+9
-3
lines changed

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ public function deleteFile($target)
543543
*/
544544
public function uploadFile($targetPath, $type = null)
545545
{
546-
$targetPath = $this->file->getRealPathSafety($targetPath) . DIRECTORY_SEPARATOR;
546+
$targetPath = $this->file->getRealPathSafety($targetPath);
547+
548+
if ($this->file->isDirectory($targetPath)) {
549+
$targetPath = $targetPath . DIRECTORY_SEPARATOR;
550+
}
547551

548552
if (!$this->isPathAllowed($targetPath, $this->getConditionsForExcludeDirs()) || strlen($targetPath) > 255) {
549553
throw new \Magento\Framework\Exception\LocalizedException(

lib/internal/Magento/Framework/Filesystem/Directory/Read.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,16 @@ public function isExist($path = null)
209209
{
210210
$this->validatePath($path);
211211

212-
return $this->driver->isExists($this->driver->getAbsolutePath($this->path, $path));
212+
return $this->driver->isExists(
213+
$this->driver->getRealPathSafety($this->driver->getAbsolutePath($this->path, $path))
214+
);
213215
}
214216

215217
/**
216218
* Gathers the statistics of the given path
217219
*
218220
* @param string $path
219-
* @return array
221+
* @return arrays
220222
* @throws \Magento\Framework\Exception\FileSystemException
221223
* @throws ValidatorException
222224
*/

0 commit comments

Comments
 (0)