From b2f62bc06c398bd7cc9742ca1fe2aa8fd982ba0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20Miguel=20Pe=CC=81rez=20Ruiz?= Date: Thu, 16 Mar 2017 01:43:54 +0100 Subject: [PATCH] Fix Init Command to accept author names with Unicode combining diacritical marks --- src/Composer/Command/InitCommand.php | 2 +- tests/Composer/Test/Command/InitCommandTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 7c3ce96f5..94ac109fc 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -320,7 +320,7 @@ EOT */ public function parseAuthorString($author) { - if (preg_match('/^(?P[- .,\p{L}\p{N}\'’"()]+) <(?P.+?)>$/u', $author, $match)) { + if (preg_match('/^(?P[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?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 23bc32acb..81aaf0d17 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -33,6 +33,16 @@ class InitCommandTest extends TestCase $this->assertEquals('matti@example.com', $author['email']); } + public function testParseValidUtf8AuthorStringWithNonSpacingMarks() + { + // \xCC\x88 is UTF-8 for U+0308 diaeresis (umlaut) combining mark + $utf8_expected = "Matti Meika\xCC\x88la\xCC\x88inen"; + $command = new InitCommand; + $author = $command->parseAuthorString($utf8_expected." "); + $this->assertEquals($utf8_expected, $author['name']); + $this->assertEquals('matti@example.com', $author['email']); + } + public function testParseNumericAuthorString() { $command = new InitCommand;