diff --git a/src/actions/FileAction.php b/src/actions/FileAction.php index 1b436ff..439dc0a 100644 --- a/src/actions/FileAction.php +++ b/src/actions/FileAction.php @@ -34,8 +34,6 @@ */ class FileAction extends Action { - const FILENAME_SEPARATOR = 'fname-'; - /** * @var string filesystem config component (fs) */ @@ -54,9 +52,7 @@ public function run($data = null) $filesystem = Yii::$app->get($this->component); try { - [$dataEncrypt, $filename] = explode(self::FILENAME_SEPARATOR, $data); - - $params = Json::decode($filesystem->/** @scrutinizer ignore-call */decrypt($dataEncrypt)); + $params = Json::decode($filesystem->/** @scrutinizer ignore-call */decrypt($data)); $now = (int) (new DateTimeImmutable())->getTimestamp(); $expires = (int) $params['expires']; @@ -66,10 +62,6 @@ public function run($data = null) } $attachmentName = (string) pathinfo($params['path'], PATHINFO_BASENAME); - if ($filename !== $attachmentName) { - throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')); - } - $content = $filesystem->read($params['path']); $mimeType = $filesystem->mimeType($params['path']); } catch (\Throwable $th) { diff --git a/src/traits/UrlGeneratorAdapterTrait.php b/src/traits/UrlGeneratorAdapterTrait.php index a44c4d0..5009467 100644 --- a/src/traits/UrlGeneratorAdapterTrait.php +++ b/src/traits/UrlGeneratorAdapterTrait.php @@ -4,7 +4,6 @@ use DateTimeInterface; use diecoding\flysystem\AbstractComponent; -use diecoding\flysystem\actions\FileAction; use League\Flysystem\Config; use League\Flysystem\PathPrefixer; use yii\helpers\Json; @@ -61,8 +60,7 @@ public function temporaryUrl(string $path, DateTimeInterface $expiresAt, /** @sc private function generateUrlAction(array $params): string { - $attachmentName = (string) pathinfo($params['path'], PATHINFO_BASENAME); - $data = $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params)) . FileAction::FILENAME_SEPARATOR . $attachmentName; + $data = $this->component->/** @scrutinizer ignore-call */encrypt(Json::encode($params)); return Url::toRoute([$this->component->action, 'data' => $data], true); }