people: Fix issues with client_gravatar and upper-case emails.

We weren't properly canonicalizing user email addresses when consuming
gravatar URLs.

See http://en.gravatar.com/site/implement/hash/ for the specification.

Fixes #9357.
This commit is contained in:
Tim Abbott
2018-05-10 12:18:23 -07:00
parent 39e461a31b
commit 4abbfe9154
3 changed files with 6 additions and 4 deletions

View File

@@ -194,6 +194,7 @@ stream_data.add_sub('stream_two', two);
var message_1 = { var message_1 = {
id: 1000, id: 1000,
content: '@-mentions the user', content: '@-mentions the user',
avatar_url: 'url',
sent_by_me: false, sent_by_me: false,
notification_sent: false, notification_sent: false,
mentioned_me_directly: true, mentioned_me_directly: true,
@@ -205,6 +206,7 @@ stream_data.add_sub('stream_two', two);
var message_2 = { var message_2 = {
id: 1500, id: 1500,
avatar_url: 'url',
content: '@-mentions the user', content: '@-mentions the user',
sent_by_me: false, sent_by_me: false,
notification_sent: false, notification_sent: false,

View File

@@ -371,7 +371,7 @@ initialize();
avatar_url: 'charles.com/foo.png', avatar_url: 'charles.com/foo.png',
}; };
var maria = { var maria = {
email: 'athens@example.com', email: 'Athens@example.com',
user_id: 452, user_id: 452,
full_name: 'Maria Athens', full_name: 'Maria Athens',
}; };
@@ -391,7 +391,7 @@ initialize();
}; };
assert.equal(people.pm_with_url(message), '#narrow/pm-with/451,452-group'); assert.equal(people.pm_with_url(message), '#narrow/pm-with/451,452-group');
assert.equal(people.pm_reply_to(message), assert.equal(people.pm_reply_to(message),
'athens@example.com,charles@example.com'); 'Athens@example.com,charles@example.com');
assert.equal(people.small_avatar_url(message), assert.equal(people.small_avatar_url(message),
'charles.com/foo.png&s=50'); 'charles.com/foo.png&s=50');
@@ -405,7 +405,7 @@ initialize();
}; };
assert.equal(people.pm_with_url(message), '#narrow/pm-with/452-athens'); assert.equal(people.pm_with_url(message), '#narrow/pm-with/452-athens');
assert.equal(people.pm_reply_to(message), assert.equal(people.pm_reply_to(message),
'athens@example.com'); 'Athens@example.com');
assert.equal(people.small_avatar_url(message), assert.equal(people.small_avatar_url(message),
'legacy.png&s=50'); 'legacy.png&s=50');

View File

@@ -490,7 +490,7 @@ exports.sender_is_bot = function (message) {
}; };
function gravatar_url_for_email(email) { function gravatar_url_for_email(email) {
var hash = md5(email); var hash = md5(email.toLowerCase());
var avatar_url = 'https://secure.gravatar.com/avatar/' + hash + '?d=identicon'; var avatar_url = 'https://secure.gravatar.com/avatar/' + hash + '?d=identicon';
var small_avatar_url = exports.format_small_avatar_url(avatar_url); var small_avatar_url = exports.format_small_avatar_url(avatar_url);
return small_avatar_url; return small_avatar_url;