1
0
Fork 0

Merge branch '1.2'

pull/5645/head
Jordi Boggiano 2016-09-02 19:00:31 +02:00
commit 165ff07146
3 changed files with 32 additions and 1 deletions

View File

@ -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<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

@ -1137,6 +1137,10 @@ class Installer
private function updateInstallReferences(PackageInterface $package, $reference) private function updateInstallReferences(PackageInterface $package, $reference)
{ {
if (!$reference) {
return;
}
$package->setSourceReference($reference); $package->setSourceReference($reference);
$package->setDistReference($reference); $package->setDistReference($reference);

View File

@ -17,6 +17,7 @@ use Composer\TestCase;
class InitCommandTest extends TestCase class InitCommandTest extends TestCase
{ {
public function testParseValidAuthorString() public function testParseValidAuthorString()
{ {
$command = new InitCommand; $command = new InitCommand;
@ -41,6 +42,32 @@ class InitCommandTest extends TestCase
$this->assertEquals('h4x@example.com', $author['email']); $this->assertEquals('h4x@example.com', $author['email']);
} }
/**
* Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631
*/
public function testParseValidAlias1AuthorString()
{
$command = new InitCommand;
$author = $command->parseAuthorString(
'Johnathon "Johnny" Smith <john@example.com>');
$this->assertEquals('Johnathon "Johnny" Smith', $author['name'] );
$this->assertEquals('john@example.com', $author['email']);
}
/**
* Test scenario for issue #5631
* @link https://github.com/composer/composer/issues/5631 Issue #5631
*/
public function testParseValidAlias2AuthorString()
{
$command = new InitCommand;
$author = $command->parseAuthorString(
'Johnathon (Johnny) Smith <john@example.com>');
$this->assertEquals('Johnathon (Johnny) Smith', $author['name'] );
$this->assertEquals('john@example.com', $author['email']);
}
public function testParseEmptyAuthorString() public function testParseEmptyAuthorString()
{ {
$command = new InitCommand; $command = new InitCommand;