From 4abbfe91541933683034b27e85bf80ce7c77f0ec Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 10 May 2018 12:18:23 -0700 Subject: [PATCH] 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. --- frontend_tests/node_tests/notifications.js | 2 ++ frontend_tests/node_tests/people.js | 6 +++--- static/js/people.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend_tests/node_tests/notifications.js b/frontend_tests/node_tests/notifications.js index 60bd30ba6a..3eaea5957b 100644 --- a/frontend_tests/node_tests/notifications.js +++ b/frontend_tests/node_tests/notifications.js @@ -194,6 +194,7 @@ stream_data.add_sub('stream_two', two); var message_1 = { id: 1000, content: '@-mentions the user', + avatar_url: 'url', sent_by_me: false, notification_sent: false, mentioned_me_directly: true, @@ -205,6 +206,7 @@ stream_data.add_sub('stream_two', two); var message_2 = { id: 1500, + avatar_url: 'url', content: '@-mentions the user', sent_by_me: false, notification_sent: false, diff --git a/frontend_tests/node_tests/people.js b/frontend_tests/node_tests/people.js index 5d6022d27f..b48bd89c74 100644 --- a/frontend_tests/node_tests/people.js +++ b/frontend_tests/node_tests/people.js @@ -371,7 +371,7 @@ initialize(); avatar_url: 'charles.com/foo.png', }; var maria = { - email: 'athens@example.com', + email: 'Athens@example.com', user_id: 452, 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_reply_to(message), - 'athens@example.com,charles@example.com'); + 'Athens@example.com,charles@example.com'); assert.equal(people.small_avatar_url(message), '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_reply_to(message), - 'athens@example.com'); + 'Athens@example.com'); assert.equal(people.small_avatar_url(message), 'legacy.png&s=50'); diff --git a/static/js/people.js b/static/js/people.js index 01513e177f..86e8ed7a96 100644 --- a/static/js/people.js +++ b/static/js/people.js @@ -490,7 +490,7 @@ exports.sender_is_bot = function (message) { }; 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 small_avatar_url = exports.format_small_avatar_url(avatar_url); return small_avatar_url;