Skip to content

Commit

Permalink
Merge branch '2.2' into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed May 24, 2022
2 parents e496b13 + 44a52e4 commit d70b580
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion res/composer-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"name": {
"type": "string",
"description": "Package name, including 'vendor-name/' prefix.",
"pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
"pattern": "^[a-z0-9]([_.-]?[a-z0-9]++)*+/[a-z0-9](([_.]|-{1,2})?[a-z0-9]++)*+$"
},
"description": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Loader/ValidatingArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public static function hasPackageNamingError(string $name, bool $isLink = false)
return null;
}

if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]++)*+/[a-z0-9](?:(?:[_.]|-{1,2})?[a-z0-9]++)*+$}iD', $name)) {
return $name.' is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".';
}

Expand Down
3 changes: 2 additions & 1 deletion src/Composer/Util/ProcessExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,8 @@ private static function escapeArgument($argument): string
// New lines break cmd.exe command parsing
$argument = strtr($argument, "\n", ' ');

$quote = strpbrk($argument, " \t") !== false;
// In addition to whitespace, commas need quoting to preserve paths
$quote = strpbrk($argument, " \t,") !== false;
$argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
$meta = $dquotes || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);

Expand Down
4 changes: 2 additions & 2 deletions tests/Composer/Test/Json/ComposerSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public function testNamePattern(): void
$expectedError = array(
array(
'property' => 'name',
'message' => 'Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
'message' => 'Does not match the regex pattern ^[a-z0-9]([_.-]?[a-z0-9]++)*+/[a-z0-9](([_.]|-{1,2})?[a-z0-9]++)*+$',
'constraint' => 'pattern',
'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$',
'pattern' => '^[a-z0-9]([_.-]?[a-z0-9]++)*+/[a-z0-9](([_.]|-{1,2})?[a-z0-9]++)*+$',
),
);

Expand Down
3 changes: 3 additions & 0 deletions tests/Composer/Test/Util/ProcessExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public function dataEscapeArguments(): array
// no whitespace must not be quoted
'no-ws' => array('abc', 'abc', "'abc'"),

// commas must be quoted
'comma' => array('a,bc', '"a,bc"', "'a,bc'"),

// double-quotes must be backslash-escaped
'dq' => array('a"bc', 'a\^"bc', "'a\"bc'"),

Expand Down

0 comments on commit d70b580

Please sign in to comment.