diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 2533094ea..1071e949d 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -35,7 +35,7 @@ class InitCommand extends Command public function parseAuthorString($author) { - if (preg_match('/^(?P[- \.,\w\'’]+) <(?P.+?)>$/u', $author, $match)) { + if (preg_match('/^(?P[- \.,\p{L}\'’]+) <(?P.+?)>$/u', $author, $match)) { if ($this->isValidEmail($match['email'])) { return array( 'name' => trim($match['name']), diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 1794d1b77..4b295ef16 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -25,6 +25,14 @@ class InitCommandTest extends TestCase $this->assertEquals('john@example.com', $author['email']); } + public function testParseValidUtf8AuthorString() + { + $command = new InitCommand; + $author = $command->parseAuthorString('Matti Meikäläinen '); + $this->assertEquals('Matti Meikäläinen', $author['name']); + $this->assertEquals('matti@example.com', $author['email']); + } + public function testParseEmptyAuthorString() { $command = new InitCommand;