From e4b8fe85a1dec690722177215800a0e7ba633812 Mon Sep 17 00:00:00 2001 From: Colin Frei Date: Tue, 20 Nov 2012 20:54:48 +0100 Subject: [PATCH] Check --name value if it's passed in, as that's not validated anywhere --- src/Composer/Command/InitCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 36eb5d1f4..f21be1937 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -171,6 +171,12 @@ EOT // package names must be in the format foo/bar $name = $name . '/' . $name; } + } else { + if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $name)) { + throw new \InvalidArgumentException( + 'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+' + ); + } } $name = $dialog->askAndValidate(