diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9c449747..57f19204 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,3 +8,7 @@
- `session:export:view`: Added `--pretty` option to `session:export:view` command to output formatted XML.
- `session:export:view`: Ask confirmation before overwriting file.
+
+## Bug Fixes
+
+- Aliases: Allow quoted arguments
diff --git a/features/fixtures/cms.xml b/features/fixtures/cms.xml
index 09f92f8a..91457244 100644
--- a/features/fixtures/cms.xml
+++ b/features/fixtures/cms.xml
@@ -32,6 +32,11 @@
mix:shareable
+
+
+ nt:unstructured
+
+
nt:unstructured
diff --git a/features/shell_alias.feature b/features/shell_alias.feature
index fc63c54f..b22eb82a 100644
--- a/features/shell_alias.feature
+++ b/features/shell_alias.feature
@@ -7,6 +7,11 @@ Feature: Command aliases
Given that I am logged in as "testuser"
And the "cms.xml" fixtures are loaded
+ Scenario: Execute an alias with a quoted string
+ Given I execute the "ls 'cms/articles/Title with Spaces'" command
+ Then the command should not fail
+
+
Scenario Outline: Execute an alias
Given I execute the "" command
Then the command should not fail
@@ -20,9 +25,10 @@ Feature: Command aliases
| mv cms smc |
| ls |
| ls cms |
- | sl cms/articles cms/test/foobar |
+ | ln cms/articles cms/test/foobar |
| cat cms/articles/article1/title |
+
Scenario: List aliases
Given I execute the "shell:alias:list" command
Then the command should not fail
@@ -30,6 +36,3 @@ Feature: Command aliases
| Alias | Command |
| cd | shell:path:change {arg1} |
| ls | node:list {arg1} |
-
-
-
diff --git a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php
index d3dfd58c..ab59e11c 100644
--- a/src/PHPCR/Shell/Subscriber/AliasSubscriber.php
+++ b/src/PHPCR/Shell/Subscriber/AliasSubscriber.php
@@ -72,6 +72,9 @@ public function handleAlias(CommandPreRunEvent $event)
$tokens = $input->getTokens();
foreach ($tokens as $i => $token) {
+ if (strstr($token, ' ')) {
+ $token = escapeshellarg($token);
+ }
$replaces['{arg' . $i . '}'] = $token;
}