Skip to content

Commit 8fbf2d9

Browse files
committed
MC-41844: input length validation is added
1 parent 547f43b commit 8fbf2d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

AdobeStockImage/Model/Storage/Save.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
class Save
2222
{
23+
private const MAX_LENGTH = 255;
24+
2325
/**
2426
* @var Filesystem
2527
*/
@@ -49,12 +51,19 @@ public function __construct(
4951
* @param string $imageUrl
5052
* @param string $destinationPath
5153
* @return string
52-
* @throws AlreadyExistsException
54+
* @throws AlreadyExistsException | InvalidArgumentException
5355
* @throws FileSystemException
5456
*/
5557
public function execute(string $imageUrl, string $destinationPath = '') : string
5658
{
5759
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
60+
$maxFilenameLength = self::MAX_LENGTH;
61+
62+
if (strlen($destinationPath) > $maxFilenameLength) {
63+
throw new \LengthException(
64+
__('Destination path is too long; must be %1 characters or less', $maxFilenameLength)
65+
);
66+
}
5867

5968
if ($mediaDirectory->isExist($destinationPath)) {
6069
throw new AlreadyExistsException(__('Image with the same file name already exits.'));

0 commit comments

Comments
 (0)