1
0
Fork 0

Init command - diacritical marks in author name

pull/2114/head
Przemysław Piechota 2013-07-25 22:40:41 +02:00
parent 3ffad59719
commit 95cbb177dd
2 changed files with 9 additions and 1 deletions

View File

@ -35,7 +35,7 @@ class InitCommand extends Command
public function parseAuthorString($author) public function parseAuthorString($author)
{ {
if (preg_match('/^(?P<name>[- \.,\w\']+) <(?P<email>.+?)>$/u', $author, $match)) { if (preg_match('/^(?P<name>[- \.,\p{L}\']+) <(?P<email>.+?)>$/u', $author, $match)) {
if ($this->isValidEmail($match['email'])) { if ($this->isValidEmail($match['email'])) {
return array( return array(
'name' => trim($match['name']), 'name' => trim($match['name']),

View File

@ -25,6 +25,14 @@ class InitCommandTest extends TestCase
$this->assertEquals('john@example.com', $author['email']); $this->assertEquals('john@example.com', $author['email']);
} }
public function testParseValidUtf8AuthorString()
{
$command = new InitCommand;
$author = $command->parseAuthorString('Matti Meikäläinen <matti@example.com>');
$this->assertEquals('Matti Meikäläinen', $author['name']);
$this->assertEquals('matti@example.com', $author['email']);
}
public function testParseEmptyAuthorString() public function testParseEmptyAuthorString()
{ {
$command = new InitCommand; $command = new InitCommand;