From b99d9465c1100143ff70cce9b2a25a945206fa09 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Mon, 20 Apr 2015 13:09:18 +0200 Subject: [PATCH 1/2] Added testcase --- tests/Composer/Test/Command/InitCommandTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index dbcbe0bda..7795a4674 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -33,6 +33,14 @@ class InitCommandTest extends TestCase $this->assertEquals('matti@example.com', $author['email']); } + public function testParseNumericAuthorString() + { + $command = new InitCommand; + $author = $command->parseAuthorString('h4x0r '); + $this->assertEquals('h4x0r', $author['name']); + $this->assertEquals('h4x@example.com', $author['email']); + } + public function testParseEmptyAuthorString() { $command = new InitCommand; From c7d387f5991cf022a2da2d315202d3e91156886e Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Mon, 20 Apr 2015 13:09:25 +0200 Subject: [PATCH 2/2] Allow numeric characters --- src/Composer/Command/InitCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index e8826687a..d68a1e38c 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -40,7 +40,7 @@ class InitCommand extends Command public function parseAuthorString($author) { - if (preg_match('/^(?P[- \.,\p{L}\'’]+) <(?P.+?)>$/u', $author, $match)) { + if (preg_match('/^(?P[- \.,\p{L}\p{N}\'’]+) <(?P.+?)>$/u', $author, $match)) { if ($this->isValidEmail($match['email'])) { return array( 'name' => trim($match['name']),