From ae7e5e063624d4682eaa7df15518644f447db51f Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 7 Sep 2021 18:59:01 +0530 Subject: [PATCH] remove more XXX notes, add stricter team invite link content validation --- www/common/common-ui-elements.js | 2 +- www/profile/inner.js | 4 ++-- www/teams/inner.js | 15 +++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index ea0edf9a5..08e0bcf07 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -3616,7 +3616,7 @@ define([ }); var displayName = UI.getDisplayName(data.name); - common.displayAvatar($(avatar), data.avatar, displayName); // XXX + common.displayAvatar($(avatar), data.avatar, displayName); return h('span.cp-mentions', { 'data-curve': data.curvePublic, 'data-notifications': data.notifications, diff --git a/www/profile/inner.js b/www/profile/inner.js index 0b720940b..2d63d2957 100644 --- a/www/profile/inner.js +++ b/www/profile/inner.js @@ -348,7 +348,7 @@ define([ if (!val) { $('', { src: '/customize/images/avatar.png', - title: Messages.profile_avatar, // XXX + title: Messages.profile_defaultAlt, alt: Messages.profile_defaultAlt, }).appendTo($span); return; @@ -391,7 +391,7 @@ define([ }, function () { sframeChan.query("Q_PROFILE_AVATAR_ADD", data.url, function (err, err2) { if (err || err2) { return void UI.log(err || err2); } - displayAvatar(data.url); // XXX add "Profile picture" + displayAvatar(data.url); }); }); }; diff --git a/www/teams/inner.js b/www/teams/inner.js index 485923996..0a524a824 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -1099,8 +1099,8 @@ define([ if (!val) { var $img = $('', { src: '/customize/images/avatar.png', - title: Messages.profile_avatar, // XXX - alt: 'Avatar' + title: Messages.profile_defaultAlt, + alt: Messages.profile_defaultAlt, }); var mt = h('media-tag', $img[0]); $avatar.append(mt); @@ -1323,16 +1323,23 @@ define([ }); }; + var isValidInvitationLinkContent = function (json) { + if (!json) { return false; } + if (json.error || !Object.keys(json).length) { return false; } + if (!json.author) { return false; } + return true; + }; + nThen(function (waitFor) { // Get preview content. sframeChan.query('Q_ANON_GET_PREVIEW_CONTENT', { seeds: seeds }, waitFor(function (err, json) { - if (json && (json.error || !Object.keys(json).length)) { // XXX team invite links are triggering this every time for me? + if (!isValidInvitationLinkContent(json)) { $(errorBlock).text(Messages.team_inviteInvalidLinkError).show(); waitFor.abort(); $div.empty(); return; } - // XXX nothing guarantees that author, teamName, or message exist in json + // FIXME nothing guarantees that teamName or author.displayName exist in json $div.empty(); $div.append(h('div.cp-teams-invite-from', [ Messages.team_inviteFrom,