diff --git a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
index f535c2cd39..53e4ffed39 100644
--- a/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
+++ b/lib/Alchemy/Phrasea/Command/Plugin/AbstractPluginCommand.php
@@ -15,6 +15,21 @@ use Alchemy\Phrasea\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+function normalizePath($path) {
+ return array_reduce(explode('/', $path), function ($a, $b) {
+ if($a === 0)
+ $a = '/';
+
+ if($b === '' || $b === '.')
+ return $a;
+
+ if($b === '..')
+ return dirname($a);
+
+ return preg_replace('/\/+/', '/', "$a/$b");
+ }, 0);
+}
+
abstract class AbstractPluginCommand extends Command
{
protected function validatePlugins(InputInterface $input, OutputInterface $output)
@@ -54,13 +69,12 @@ abstract class AbstractPluginCommand extends Command
protected function doInstallPlugin($source, InputInterface $input, OutputInterface $output)
{
-
$output->write("Validating plugin...");
$manifest = $this->container['plugins.plugins-validator']->validatePlugin($source);
$output->writeln(" OK found ".$manifest->getName()."");
$targetDir = $this->container['plugin.path'] . DIRECTORY_SEPARATOR . $manifest->getName();
- if (realpath($targetDir) !== realpath($source)) {
+ if (normalizePath($targetDir) !== normalizePath($source)) {
$temporaryDir = $this->container['temporary-filesystem']->createTemporaryDirectory();
$output->write("Importing $source...");
$this->container['plugins.importer']->import($source, $temporaryDir);
diff --git a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php
index 523b4c00da..506c4f104a 100644
--- a/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php
+++ b/tests/Alchemy/Tests/Phrasea/Command/Plugin/AddPluginTest.php
@@ -69,7 +69,7 @@ class AddPluginTest extends PluginCommandTestCase
// the plugin is checked when updating config files
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(0))
->method('validatePlugin')
- ->with('tempdir')
+ ->with('TestPlugin')
->will($this->returnValue($manifest));
self::$DI['cli']['plugins.plugins-validator']->expects($this->at(1))