Skip to content

Commit 3a7e038

Browse files
committed
[FrameworkBundle] sanitize target arg in asset:install command
1 parent 41b25a4 commit 3a7e038

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ protected function configure()
6161
*/
6262
protected function execute(InputInterface $input, OutputInterface $output)
6363
{
64-
if (!is_dir($input->getArgument('target'))) {
64+
$targetArg = rtrim($input->getArgument('target'), '/');
65+
66+
if (!is_dir($targetArg)) {
6567
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
6668
}
6769

@@ -72,11 +74,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
7274
$filesystem = $this->getContainer()->get('filesystem');
7375

7476
// Create the bundles directory otherwise symlink will fail.
75-
$filesystem->mkdir($input->getArgument('target').'/bundles/', 0777);
77+
$filesystem->mkdir($targetArg.'/bundles/', 0777);
7678

7779
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
7880
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
79-
$targetDir = $input->getArgument('target').'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
81+
$targetDir = $targetArg.'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
8082

8183
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
8284

0 commit comments

Comments
 (0)