Skip to content

Commit 4bbc110

Browse files
committed
MC-41838: Simplify paths
1 parent 33a090f commit 4bbc110

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class Save
2424
{
2525
private const IMAGE_FILE_NAME_PATTERN = '#\.(jpg|jpeg|gif|png)$# i';
26+
private const MAX_LENGTH = 255;
2627

2728
/**
2829
* @var Filesystem
@@ -66,6 +67,14 @@ public function __construct(
6667
*/
6768
public function execute(string $imageUrl, string $destinationPath, bool $allowOverwrite = false): void
6869
{
70+
$maxFilenameLength = self::MAX_LENGTH;
71+
72+
if (strlen($destinationPath) > $maxFilenameLength) {
73+
throw new \LengthException(
74+
__('Destination Path is too long; must be %1 characters or less', $maxFilenameLength)
75+
);
76+
}
77+
6978
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
7079

7180
if ($this->isPathExcluded->execute($destinationPath)) {

0 commit comments

Comments
 (0)