Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
escape nicknames before displaying them
isymchych0bcbd105e392
diff --git a/modules/UI/UI.js b/modules/UI/UI.jsindex 9515dec656..fc58504d02 100644--- a/modules/UI/UI.js+++ b/modules/UI/UI.js@@ -223,12 +223,13 @@ UI.changeDisplayName = function (id, displayName) {* Intitialize conference UI.*/UI.initConference = function () {- var id = APP.conference.localId;+ let id = APP.conference.localId;Toolbar.updateRoomUrl(window.location.href);- var meHTML = APP.translation.generateTranslationHTML("me");- var settings = Settings.getSettings();+ let meHTML = APP.translation.generateTranslationHTML("me");- $("#localNick").html(settings.email || settings.uid + " (" + meHTML + ")");+ let email = Settings.getEmail();+ let uid = Settings.getUserId();+ $("#localNick").html(email || `${uid} (${meHTML})`);// Add myself to the contact list.ContactList.addContact(id);@@ -236,14 +237,14 @@ UI.initConference = function () {// Once we've joined the muc show the toolbarToolbarToggler.showToolbar();- var displayName = config.displayJids ? id : settings.displayName;+ let displayName = config.displayJids ? id : Settings.getDisplayName();if (displayName) {UI.changeDisplayName('localVideoContainer', displayName);}// Make sure we configure our avatar id, before creating avatar for us- UI.setUserAvatar(id, settings.email);+ UI.setUserAvatar(id, email);Toolbar.checkAutoEnableDesktopSharing();if(!interfaceConfig.filmStripOnly) {@@ -607,8 +608,11 @@ UI.toggleContactList = function () {PanelToggler.toggleContactList();};-UI.inputDisplayNameHandler = function (value) {- VideoLayout.inputDisplayNameHandler(value);+/**+ * Handle new user display name.+ */+UI.inputDisplayNameHandler = function (newDisplayName) {+ eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);};/**@@ -888,7 +892,7 @@ UI.inviteParticipants = function (roomUrl, conferenceName, key, nick) {body = body.replace(/\n/g, "%0D%0A");if (nick) {- body += "%0D%0A%0D%0A" + nick;+ body += "%0D%0A%0D%0A" + UIUtil.escapeHtml(nick);}if (interfaceConfig.INVITATION_POWERED_BY) {diff --git a/modules/UI/side_pannels/SidePanelToggler.js b/modules/UI/side_pannels/SidePanelToggler.jsindex f3742a2cd5..55836556cd 100644--- a/modules/UI/side_pannels/SidePanelToggler.js+++ b/modules/UI/side_pannels/SidePanelToggler.js@@ -148,9 +148,8 @@ var PanelToggler = {'#settingsmenu',null,function() {- var settings = Settings.getSettings();- $('#setDisplayName').get(0).value = settings.displayName;- $('#setEmail').get(0).value = settings.email;+ $('#setDisplayName').val(Settings.getDisplayName());+ $('#setEmail').val(Settings.getEmail());},null);},diff --git a/modules/UI/side_pannels/chat/Chat.js b/modules/UI/side_pannels/chat/Chat.jsindex 743daea612..3c2fadac7c 100644--- a/modules/UI/side_pannels/chat/Chat.js+++ b/modules/UI/side_pannels/chat/Chat.js@@ -179,7 +179,7 @@ var Chat = {$('#nickinput').keydown(function (event) {if (event.keyCode === 13) {event.preventDefault();- var val = UIUtil.escapeHtml(this.value);+ let val = this.value;this.value = '';eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);}diff --git a/modules/UI/side_pannels/contactlist/ContactList.js b/modules/UI/side_pannels/contactlist/ContactList.jsindex 05236a8498..aa743afa9c 100644--- a/modules/UI/side_pannels/contactlist/ContactList.js+++ b/modules/UI/side_pannels/contactlist/ContactList.js@@ -158,7 +158,7 @@ var ContactList = {let contactName = $(`#contacts #${id}>p`);if (displayName) {- contactName.html(displayName);+ contactName.text(displayName);}},diff --git a/modules/UI/side_pannels/settings/SettingsMenu.js b/modules/UI/side_pannels/settings/SettingsMenu.jsindex 950ee09687..d44be09bbb 100644--- a/modules/UI/side_pannels/settings/SettingsMenu.js+++ b/modules/UI/side_pannels/settings/SettingsMenu.js@@ -40,7 +40,7 @@ function generateDevicesOptions(items, selectedId) {export default {init (emitter) {function update() {- let displayName = UIUtil.escapeHtml($('#setDisplayName').val());+ let displayName = $('#setDisplayName').val();if (displayName && Settings.getDisplayName() !== displayName) {emitter.emit(UIEvents.NICKNAME_CHANGED, displayName);diff --git a/modules/UI/util/MessageHandler.js b/modules/UI/util/MessageHandler.jsindex 80c7814727..0130b10c0f 100644--- a/modules/UI/util/MessageHandler.js+++ b/modules/UI/util/MessageHandler.js@@ -1,6 +1,8 @@/* global $, APP, jQuery, toastr, Impromptu *//* jshint -W101 */+import UIUtil from './UIUtil';+/*** Flag for enable/disable of the notifications.* @type {boolean}@@ -204,7 +206,7 @@ var messageHandler = (function(my) {return;var displayNameSpan = '<span class="nickname" ';if (displayName) {- displayNameSpan += ">" + displayName;+ displayNameSpan += ">" + UIUtil.escapeHtml(displayName);} else {displayNameSpan += "data-i18n='" + displayNameKey +"'>" + APP.translation.translateString(displayNameKey);@@ -247,5 +249,3 @@ var messageHandler = (function(my) {}(messageHandler || {}));module.exports = messageHandler;--diff --git a/modules/UI/util/UIUtil.js b/modules/UI/util/UIUtil.jsindex 519d66f30d..50d9f85fa3 100644--- a/modules/UI/util/UIUtil.js+++ b/modules/UI/util/UIUtil.js@@ -72,6 +72,16 @@return $('<div/>').text(unsafeText).html();},+ /**+ * Unescapes the given text.+ *+ * @param {string} safe string which contains escaped html+ * @returns {string} unescaped html string.+ */+ unescapeHtml: function (safe) {+ return $('<div />').html(safe).text();+ },+imageToGrayScale: function (canvas) {var context = canvas.getContext('2d');var imgData = context.getImageData(0, 0, canvas.width, canvas.height);diff --git a/modules/UI/videolayout/LocalVideo.js b/modules/UI/videolayout/LocalVideo.jsindex e631e6a43c..e339be4e20 100644--- a/modules/UI/videolayout/LocalVideo.js+++ b/modules/UI/videolayout/LocalVideo.js@@ -65,7 +65,9 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {if (nameSpan.text() !== displayName) {if (displayName && displayName.length > 0) {meHTML = APP.translation.generateTranslationHTML("me");- $('#localDisplayName').html(displayName + ' (' + meHTML + ')');+ $('#localDisplayName').html(+ UIUtil.escapeHtml(displayName) + ' (' + meHTML + ')'+ );} else {$('#localDisplayName').html(defaultLocalDisplayName);}@@ -81,7 +83,7 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {if (displayName && displayName.length > 0) {meHTML = APP.translation.generateTranslationHTML("me");- nameSpan.innerHTML = displayName + meHTML;+ nameSpan.innerHTML = UIUtil.escapeHtml(displayName) + meHTML;}else {nameSpan.innerHTML = defaultLocalDisplayName;@@ -126,7 +128,7 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {editDisplayName.select();editDisplayName.one("focusout", function (e) {- self.VideoLayout.inputDisplayNameHandler(this.value);+ self.emitter.emit(UIEvents.NICKNAME_CHANGED, this.value);$('#editDisplayName').hide();});@@ -141,10 +143,6 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {}};-LocalVideo.prototype.inputDisplayNameHandler = function (name) {- this.emitter.emit(UIEvents.NICKNAME_CHANGED, UIUtil.escapeHtml(name));-};-LocalVideo.prototype.createConnectionIndicator = function() {if(this.connectionIndicator)return;diff --git a/modules/UI/videolayout/RemoteVideo.js b/modules/UI/videolayout/RemoteVideo.jsindex 92462e8d58..7683c671fd 100644--- a/modules/UI/videolayout/RemoteVideo.js+++ b/modules/UI/videolayout/RemoteVideo.js@@ -359,7 +359,7 @@ RemoteVideo.prototype.setDisplayName = function(displayName, key) {// If we already have a display name for this video.if (nameSpan.length > 0) {if (displayName && displayName.length > 0) {- $('#' + this.videoSpanId + '_name').html(displayName);+ $('#' + this.videoSpanId + '_name').text(displayName);}else if (key && key.length > 0) {var nameHtml = APP.translation.generateTranslationHTML(key);@@ -374,10 +374,10 @@ RemoteVideo.prototype.setDisplayName = function(displayName, key) {$('#' + this.videoSpanId)[0].appendChild(nameSpan);if (displayName && displayName.length > 0) {- nameSpan.innerHTML = displayName;- }- else+ $(nameSpan).text(displayName);+ } else {nameSpan.innerHTML = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;+ }nameSpan.id = this.videoSpanId + '_name';}};diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.jsindex 53143fd20e..15502b3eec 100644--- a/modules/UI/videolayout/VideoLayout.js+++ b/modules/UI/videolayout/VideoLayout.js@@ -347,11 +347,6 @@ var VideoLayout = {}},-- inputDisplayNameHandler (name) {- localVideoThumbnail.inputDisplayNameHandler(name);- },-videoactive (videoelem, resourceJid) {console.info(resourceJid + " video is now active", videoelem);diff --git a/modules/settings/Settings.js b/modules/settings/Settings.jsindex ced1aeeb08..7ffe4a667d 100644--- a/modules/settings/Settings.js+++ b/modules/settings/Settings.js@@ -1,4 +1,5 @@import {generateUsername} from '../util/UsernameGenerator';+import UIUtil from '../UI/util/UIUtil';let email = '';let displayName = '';@@ -32,7 +33,7 @@ if (supportsLocalStorage()) {userId = window.localStorage.jitsiMeetId || '';email = window.localStorage.email || '';- displayName = window.localStorage.displayname || '';+ displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');language = window.localStorage.language;cameraDeviceId = window.localStorage.cameraDeviceId || '';micDeviceId = window.localStorage.micDeviceId || '';@@ -46,26 +47,29 @@ export default {/*** Sets the local user display name and saves it to local storage*- * @param newDisplayName the new display name for the local user- * @returns {string} the display name we just set+ * @param {string} newDisplayName unescaped display name for the local user*/- setDisplayName: function (newDisplayName) {- if (displayName === newDisplayName) {- return displayName;- }+ setDisplayName (newDisplayName) {displayName = newDisplayName;- window.localStorage.displayname = displayName;- return displayName;+ window.localStorage.displayname = UIUtil.escapeHtml(displayName);},/**- * Returns the currently used by the user+ * Returns the escaped display name currently used by the user* @returns {string} currently valid user display name.*/getDisplayName: function () {return displayName;},+ /**+ * Returns id of the user.+ * @returns {string} user id+ */+ getUserId () {+ return userId;+ },+setEmail: function (newEmail) {email = newEmail;window.localStorage.email = newEmail;