Fix Init Command to accept author names with Unicode combining diacritical marks
parent
a4c9c1235e
commit
4ba3c741f5
|
@ -320,7 +320,7 @@ EOT
|
||||||
*/
|
*/
|
||||||
public function parseAuthorString($author)
|
public function parseAuthorString($author)
|
||||||
{
|
{
|
||||||
if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
|
if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?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']),
|
||||||
|
|
|
@ -33,6 +33,16 @@ class InitCommandTest extends TestCase
|
||||||
$this->assertEquals('matti@example.com', $author['email']);
|
$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." <matti@example.com>");
|
||||||
|
$this->assertEquals($utf8_expected, $author['name']);
|
||||||
|
$this->assertEquals('matti@example.com', $author['email']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testParseNumericAuthorString()
|
public function testParseNumericAuthorString()
|
||||||
{
|
{
|
||||||
$command = new InitCommand;
|
$command = new InitCommand;
|
||||||
|
|
Loading…
Reference in New Issue