Skip to content

Commit 3f44039

Browse files
committed
Merge pull request #37 from phpcr/aliases_quoted_args
Aliases do not resepect parenthesis escaping
2 parents feaafe7 + 9850f23 commit 3f44039

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99

1010
- `session:export:view`: Added `--pretty` option to `session:export:view` command to output formatted XML.
1111
- `session:export:view`: Ask confirmation before overwriting file.
12+
13+
## Bug Fixes
14+
15+
- Aliases: Allow quoted arguments

features/fixtures/cms.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<sv:property sv:name="jcr:mixinTypes" sv:type="name">
3333
<sv:value>mix:shareable</sv:value>
3434
</sv:property>
35+
<sv:node sv:name="Title with Spaces">
36+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
37+
<sv:value>nt:unstructured</sv:value>
38+
</sv:property>
39+
</sv:node>
3540
<sv:node sv:name="article1">
3641
<sv:property sv:name="jcr:primaryType" sv:type="Name">
3742
<sv:value>nt:unstructured</sv:value>

features/shell_alias.feature

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Feature: Command aliases
77
Given that I am logged in as "testuser"
88
And the "cms.xml" fixtures are loaded
99

10+
Scenario: Execute an alias with a quoted string
11+
Given I execute the "ls 'cms/articles/Title with Spaces'" command
12+
Then the command should not fail
13+
14+
1015
Scenario Outline: Execute an alias
1116
Given I execute the "<command>" command
1217
Then the command should not fail
@@ -20,16 +25,14 @@ Feature: Command aliases
2025
| mv cms smc |
2126
| ls |
2227
| ls cms |
23-
| sl cms/articles cms/test/foobar |
28+
| ln cms/articles cms/test/foobar |
2429
| cat cms/articles/article1/title |
2530

31+
2632
Scenario: List aliases
2733
Given I execute the "shell:alias:list" command
2834
Then the command should not fail
2935
And I should see a table containing the following rows:
3036
| Alias | Command |
3137
| cd | shell:path:change {arg1} |
3238
| ls | node:list {arg1} |
33-
34-
35-

src/PHPCR/Shell/Subscriber/AliasSubscriber.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ public function handleAlias(CommandPreRunEvent $event)
7272
$tokens = $input->getTokens();
7373

7474
foreach ($tokens as $i => $token) {
75+
if (strstr($token, ' ')) {
76+
$token = escapeshellarg($token);
77+
}
7578
$replaces['{arg' . $i . '}'] = $token;
7679
}
7780

0 commit comments

Comments
 (0)