Skip to content

Commit 2342ecf

Browse files
Fixes #3510: Fix up regular expressions for remote site specifications. (#3583)
* Fixes #3510: Fix up regular expressions for remote site specifications. * Fixes #3263: Also allow dots in the username part of site specifications.
1 parent 6f2aef7 commit 2342ecf

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

isolation/tests/SiteSpecParserTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ public static function validSiteSpecs()
6464
return [
6565
[ '/path/to/drupal#uri' ],
6666
[ 'user@server/path/to/drupal#uri' ],
67+
[ '[email protected]/path/to/drupal#uri' ],
6768
[ 'user@server/path/to/drupal' ],
69+
[ '[email protected]/path/to/drupal' ],
6870
[ 'user@server#uri' ],
71+
[ '[email protected]#uri' ],
6972
[ '#uri' ],
7073
];
7174
}
@@ -97,6 +100,16 @@ public static function parserTestValues()
97100
],
98101
],
99102

103+
[
104+
'[email protected]/path#somemultisite',
105+
[
106+
'user' => 'user.name',
107+
'host' => 'example.com',
108+
'root' => '/path',
109+
'uri' => 'somemultisite',
110+
],
111+
],
112+
100113
[
101114
'user@server/path',
102115
[
@@ -107,6 +120,16 @@ public static function parserTestValues()
107120
],
108121
],
109122

123+
[
124+
125+
[
126+
'user' => 'user.name',
127+
'host' => 'example.com',
128+
'root' => '/path',
129+
'uri' => 'default',
130+
],
131+
],
132+
110133
[
111134
'/fixtures#mymultisite',
112135
[

src/Preflight/ArgsPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function parse($argv, PreflightArgsInterface $storage)
6464
return $storage->passArgs($argv);
6565
}
6666

67-
if ($this->isAliasOrSiteSpec($opt) && !$storage->hasAlias() && !$sawArg) {
67+
if (!$sawArg && !$storage->hasAlias() && $this->isAliasOrSiteSpec($opt)) {
6868
$storage->setAlias($opt);
6969
continue;
7070
}

src/SiteAlias/SiteSpecParser.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,39 @@ public function isAliasName($aliasName)
7777
*/
7878
protected function patterns()
7979
{
80+
$PATH = '(/[^#]*)';
81+
$USER = '([a-zA-Z0-9\._-]+)';
82+
$SERVER = '([a-zA-Z0-9\._-]+)';
83+
$URI = '([a-zA-Z0-9_-]+)';
84+
8085
return [
8186
// /path/to/drupal#uri
82-
'%^(/[^#]*)#([a-zA-Z0-9_-]+)$%' => [
87+
"%^{$PATH}#{$URI}\$%" => [
8388
'root' => 1,
8489
'uri' => 2,
8590
],
8691
// user@server/path/to/drupal#uri
87-
'%^([a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)(/[^#]*)#([a-zA-Z0-9_-]+)$%' => [
92+
"%^{$USER}@{$SERVER}{$PATH}#{$URI}\$%" => [
8893
'user' => 1,
8994
'host' => 2,
9095
'root' => 3,
9196
'uri' => 4,
9297
],
9398
// user@server/path/to/drupal
94-
'%^([a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)(/[^#]*)$%' => [
99+
"%^{$USER}@{$SERVER}{$PATH}\$%" => [
95100
'user' => 1,
96101
'host' => 2,
97102
'root' => 3,
98103
'uri' => 'default', // Or '2' if uri should be 'host'
99104
],
100105
// user@server#uri
101-
'%^([a-zA-Z0-9_-]+)@([a-zA-Z0-9_-]+)#([a-zA-Z0-9_-]+)$%' => [
106+
"%^{$USER}@{$SERVER}#{$URI}\$%" => [
102107
'user' => 1,
103108
'host' => 2,
104109
'uri' => 3,
105110
],
106111
// #uri
107-
'%^#([a-zA-Z0-9_-]+)$%' => [
112+
"%^#{$URI}\$%" => [
108113
'uri' => 1,
109114
],
110115
];

0 commit comments

Comments
 (0)