From 95cbb177dd5c84fadf7250eede19cf3ff2fa5e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Piechota?= Date: Thu, 25 Jul 2013 22:40:41 +0200 Subject: [PATCH] Init command - diacritical marks in author name --- src/Composer/Command/InitCommand.php | 2 +- tests/Composer/Test/Command/InitCommandTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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;