escape nicknames before displaying them
This commit is contained in:
parent
47f2320e94
commit
0bcbd105e3
|
@ -223,12 +223,13 @@ UI.changeDisplayName = function (id, displayName) {
|
||||||
* Intitialize conference UI.
|
* Intitialize conference UI.
|
||||||
*/
|
*/
|
||||||
UI.initConference = function () {
|
UI.initConference = function () {
|
||||||
var id = APP.conference.localId;
|
let id = APP.conference.localId;
|
||||||
Toolbar.updateRoomUrl(window.location.href);
|
Toolbar.updateRoomUrl(window.location.href);
|
||||||
var meHTML = APP.translation.generateTranslationHTML("me");
|
let meHTML = APP.translation.generateTranslationHTML("me");
|
||||||
var settings = Settings.getSettings();
|
|
||||||
|
|
||||||
$("#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.
|
// Add myself to the contact list.
|
||||||
ContactList.addContact(id);
|
ContactList.addContact(id);
|
||||||
|
@ -236,14 +237,14 @@ UI.initConference = function () {
|
||||||
// Once we've joined the muc show the toolbar
|
// Once we've joined the muc show the toolbar
|
||||||
ToolbarToggler.showToolbar();
|
ToolbarToggler.showToolbar();
|
||||||
|
|
||||||
var displayName = config.displayJids ? id : settings.displayName;
|
let displayName = config.displayJids ? id : Settings.getDisplayName();
|
||||||
|
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
UI.changeDisplayName('localVideoContainer', displayName);
|
UI.changeDisplayName('localVideoContainer', displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we configure our avatar id, before creating avatar for us
|
// Make sure we configure our avatar id, before creating avatar for us
|
||||||
UI.setUserAvatar(id, settings.email);
|
UI.setUserAvatar(id, email);
|
||||||
|
|
||||||
Toolbar.checkAutoEnableDesktopSharing();
|
Toolbar.checkAutoEnableDesktopSharing();
|
||||||
if(!interfaceConfig.filmStripOnly) {
|
if(!interfaceConfig.filmStripOnly) {
|
||||||
|
@ -607,8 +608,11 @@ UI.toggleContactList = function () {
|
||||||
PanelToggler.toggleContactList();
|
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");
|
body = body.replace(/\n/g, "%0D%0A");
|
||||||
|
|
||||||
if (nick) {
|
if (nick) {
|
||||||
body += "%0D%0A%0D%0A" + nick;
|
body += "%0D%0A%0D%0A" + UIUtil.escapeHtml(nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interfaceConfig.INVITATION_POWERED_BY) {
|
if (interfaceConfig.INVITATION_POWERED_BY) {
|
||||||
|
|
|
@ -148,9 +148,8 @@ var PanelToggler = {
|
||||||
'#settingsmenu',
|
'#settingsmenu',
|
||||||
null,
|
null,
|
||||||
function() {
|
function() {
|
||||||
var settings = Settings.getSettings();
|
$('#setDisplayName').val(Settings.getDisplayName());
|
||||||
$('#setDisplayName').get(0).value = settings.displayName;
|
$('#setEmail').val(Settings.getEmail());
|
||||||
$('#setEmail').get(0).value = settings.email;
|
|
||||||
},
|
},
|
||||||
null);
|
null);
|
||||||
},
|
},
|
||||||
|
|
|
@ -179,7 +179,7 @@ var Chat = {
|
||||||
$('#nickinput').keydown(function (event) {
|
$('#nickinput').keydown(function (event) {
|
||||||
if (event.keyCode === 13) {
|
if (event.keyCode === 13) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var val = UIUtil.escapeHtml(this.value);
|
let val = this.value;
|
||||||
this.value = '';
|
this.value = '';
|
||||||
eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
|
eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ var ContactList = {
|
||||||
let contactName = $(`#contacts #${id}>p`);
|
let contactName = $(`#contacts #${id}>p`);
|
||||||
|
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
contactName.html(displayName);
|
contactName.text(displayName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ function generateDevicesOptions(items, selectedId) {
|
||||||
export default {
|
export default {
|
||||||
init (emitter) {
|
init (emitter) {
|
||||||
function update() {
|
function update() {
|
||||||
let displayName = UIUtil.escapeHtml($('#setDisplayName').val());
|
let displayName = $('#setDisplayName').val();
|
||||||
|
|
||||||
if (displayName && Settings.getDisplayName() !== displayName) {
|
if (displayName && Settings.getDisplayName() !== displayName) {
|
||||||
emitter.emit(UIEvents.NICKNAME_CHANGED, displayName);
|
emitter.emit(UIEvents.NICKNAME_CHANGED, displayName);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
/* global $, APP, jQuery, toastr, Impromptu */
|
/* global $, APP, jQuery, toastr, Impromptu */
|
||||||
/* jshint -W101 */
|
/* jshint -W101 */
|
||||||
|
|
||||||
|
import UIUtil from './UIUtil';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag for enable/disable of the notifications.
|
* Flag for enable/disable of the notifications.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
|
@ -204,7 +206,7 @@ var messageHandler = (function(my) {
|
||||||
return;
|
return;
|
||||||
var displayNameSpan = '<span class="nickname" ';
|
var displayNameSpan = '<span class="nickname" ';
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
displayNameSpan += ">" + displayName;
|
displayNameSpan += ">" + UIUtil.escapeHtml(displayName);
|
||||||
} else {
|
} else {
|
||||||
displayNameSpan += "data-i18n='" + displayNameKey +
|
displayNameSpan += "data-i18n='" + displayNameKey +
|
||||||
"'>" + APP.translation.translateString(displayNameKey);
|
"'>" + APP.translation.translateString(displayNameKey);
|
||||||
|
@ -247,5 +249,3 @@ var messageHandler = (function(my) {
|
||||||
}(messageHandler || {}));
|
}(messageHandler || {}));
|
||||||
|
|
||||||
module.exports = messageHandler;
|
module.exports = messageHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,16 @@
|
||||||
return $('<div/>').text(unsafeText).html();
|
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) {
|
imageToGrayScale: function (canvas) {
|
||||||
var context = canvas.getContext('2d');
|
var context = canvas.getContext('2d');
|
||||||
var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
|
var imgData = context.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
|
|
|
@ -65,7 +65,9 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {
|
||||||
if (nameSpan.text() !== displayName) {
|
if (nameSpan.text() !== displayName) {
|
||||||
if (displayName && displayName.length > 0) {
|
if (displayName && displayName.length > 0) {
|
||||||
meHTML = APP.translation.generateTranslationHTML("me");
|
meHTML = APP.translation.generateTranslationHTML("me");
|
||||||
$('#localDisplayName').html(displayName + ' (' + meHTML + ')');
|
$('#localDisplayName').html(
|
||||||
|
UIUtil.escapeHtml(displayName) + ' (' + meHTML + ')'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$('#localDisplayName').html(defaultLocalDisplayName);
|
$('#localDisplayName').html(defaultLocalDisplayName);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +83,7 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {
|
||||||
|
|
||||||
if (displayName && displayName.length > 0) {
|
if (displayName && displayName.length > 0) {
|
||||||
meHTML = APP.translation.generateTranslationHTML("me");
|
meHTML = APP.translation.generateTranslationHTML("me");
|
||||||
nameSpan.innerHTML = displayName + meHTML;
|
nameSpan.innerHTML = UIUtil.escapeHtml(displayName) + meHTML;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nameSpan.innerHTML = defaultLocalDisplayName;
|
nameSpan.innerHTML = defaultLocalDisplayName;
|
||||||
|
@ -126,7 +128,7 @@ LocalVideo.prototype.setDisplayName = function(displayName, key) {
|
||||||
editDisplayName.select();
|
editDisplayName.select();
|
||||||
|
|
||||||
editDisplayName.one("focusout", function (e) {
|
editDisplayName.one("focusout", function (e) {
|
||||||
self.VideoLayout.inputDisplayNameHandler(this.value);
|
self.emitter.emit(UIEvents.NICKNAME_CHANGED, this.value);
|
||||||
$('#editDisplayName').hide();
|
$('#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() {
|
LocalVideo.prototype.createConnectionIndicator = function() {
|
||||||
if(this.connectionIndicator)
|
if(this.connectionIndicator)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -359,7 +359,7 @@ RemoteVideo.prototype.setDisplayName = function(displayName, key) {
|
||||||
// If we already have a display name for this video.
|
// If we already have a display name for this video.
|
||||||
if (nameSpan.length > 0) {
|
if (nameSpan.length > 0) {
|
||||||
if (displayName && displayName.length > 0) {
|
if (displayName && displayName.length > 0) {
|
||||||
$('#' + this.videoSpanId + '_name').html(displayName);
|
$('#' + this.videoSpanId + '_name').text(displayName);
|
||||||
}
|
}
|
||||||
else if (key && key.length > 0) {
|
else if (key && key.length > 0) {
|
||||||
var nameHtml = APP.translation.generateTranslationHTML(key);
|
var nameHtml = APP.translation.generateTranslationHTML(key);
|
||||||
|
@ -374,10 +374,10 @@ RemoteVideo.prototype.setDisplayName = function(displayName, key) {
|
||||||
$('#' + this.videoSpanId)[0].appendChild(nameSpan);
|
$('#' + this.videoSpanId)[0].appendChild(nameSpan);
|
||||||
|
|
||||||
if (displayName && displayName.length > 0) {
|
if (displayName && displayName.length > 0) {
|
||||||
nameSpan.innerHTML = displayName;
|
$(nameSpan).text(displayName);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
nameSpan.innerHTML = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
nameSpan.innerHTML = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
||||||
|
}
|
||||||
nameSpan.id = this.videoSpanId + '_name';
|
nameSpan.id = this.videoSpanId + '_name';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -347,11 +347,6 @@ var VideoLayout = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
inputDisplayNameHandler (name) {
|
|
||||||
localVideoThumbnail.inputDisplayNameHandler(name);
|
|
||||||
},
|
|
||||||
|
|
||||||
videoactive (videoelem, resourceJid) {
|
videoactive (videoelem, resourceJid) {
|
||||||
|
|
||||||
console.info(resourceJid + " video is now active", videoelem);
|
console.info(resourceJid + " video is now active", videoelem);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {generateUsername} from '../util/UsernameGenerator';
|
import {generateUsername} from '../util/UsernameGenerator';
|
||||||
|
import UIUtil from '../UI/util/UIUtil';
|
||||||
|
|
||||||
let email = '';
|
let email = '';
|
||||||
let displayName = '';
|
let displayName = '';
|
||||||
|
@ -32,7 +33,7 @@ if (supportsLocalStorage()) {
|
||||||
|
|
||||||
userId = window.localStorage.jitsiMeetId || '';
|
userId = window.localStorage.jitsiMeetId || '';
|
||||||
email = window.localStorage.email || '';
|
email = window.localStorage.email || '';
|
||||||
displayName = window.localStorage.displayname || '';
|
displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
|
||||||
language = window.localStorage.language;
|
language = window.localStorage.language;
|
||||||
cameraDeviceId = window.localStorage.cameraDeviceId || '';
|
cameraDeviceId = window.localStorage.cameraDeviceId || '';
|
||||||
micDeviceId = window.localStorage.micDeviceId || '';
|
micDeviceId = window.localStorage.micDeviceId || '';
|
||||||
|
@ -46,26 +47,29 @@ export default {
|
||||||
/**
|
/**
|
||||||
* Sets the local user display name and saves it to local storage
|
* Sets the local user display name and saves it to local storage
|
||||||
*
|
*
|
||||||
* @param newDisplayName the new display name for the local user
|
* @param {string} newDisplayName unescaped display name for the local user
|
||||||
* @returns {string} the display name we just set
|
|
||||||
*/
|
*/
|
||||||
setDisplayName: function (newDisplayName) {
|
setDisplayName (newDisplayName) {
|
||||||
if (displayName === newDisplayName) {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
displayName = newDisplayName;
|
displayName = newDisplayName;
|
||||||
window.localStorage.displayname = displayName;
|
window.localStorage.displayname = UIUtil.escapeHtml(displayName);
|
||||||
return 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.
|
* @returns {string} currently valid user display name.
|
||||||
*/
|
*/
|
||||||
getDisplayName: function () {
|
getDisplayName: function () {
|
||||||
return displayName;
|
return displayName;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns id of the user.
|
||||||
|
* @returns {string} user id
|
||||||
|
*/
|
||||||
|
getUserId () {
|
||||||
|
return userId;
|
||||||
|
},
|
||||||
|
|
||||||
setEmail: function (newEmail) {
|
setEmail: function (newEmail) {
|
||||||
email = newEmail;
|
email = newEmail;
|
||||||
window.localStorage.email = newEmail;
|
window.localStorage.email = newEmail;
|
||||||
|
|
Loading…
Reference in New Issue