Skip to content

Commit

Permalink
Fix wrong email used for gravatar (#1630)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin authored Jul 30, 2018
1 parent b2f824f commit 25501b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Models/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,11 @@ public function getGravatar($size)
return false;
}

if (! app('gravatar')->exists($email)) {
try {
if (! app('gravatar')->exists($email)) {
return false;
}
} catch (\Creativeorange\Gravatar\Exceptions\InvalidEmailException $e) {
return false;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/Unit/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,23 @@ public function test_gravatar_set_emailnotexists()
$this->assertNull($contact->getAvatarURL());
}

public function test_gravatar_set_emailbadformat()
{
$account = factory(Account::class)->create();
$contact = factory(Contact::class)->create(['account_id' => $account->id]);
$contactFieldType = factory(ContactFieldType::class)->create(['account_id' => $account->id]);
$contactField = factory(ContactField::class)->create([
'account_id' => $account->id,
'contact_id' => $contact->id,
'contact_field_type_id' => $contactFieldType->id,
'data' => ' bad%20<email@bad.com',
]);

$contact->updateGravatar();

$this->assertNull($contact->getAvatarURL());
}

public function test_gravatar_set_emailreal()
{
$account = factory(Account::class)->create();
Expand Down

0 comments on commit 25501b2

Please sign in to comment.