Browse Source

handle non-string id properly

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
pull/109/merge
Morris Jobke 9 years ago
parent
commit
1ebba9ea0f
No known key found for this signature in database GPG Key ID: 9CE5ED29E7FCD38A
  1. 25
      js/webrtc.js

25
js/webrtc.js

@ -140,19 +140,9 @@ var spreedMappingTable = [];
}
console.table(data);
},
unsanitizeId: function(id) {
return id.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
},
sanitizeId: function(id) {
return id.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
},
getContainerId: function(id) {
if (id === OCA.SpreedMe.XhrConnection.getSessionid()) {
return '#localVideoContainer';
} else {
var sanitizedId = OCA.SpreedMe.speakers.sanitizeId(id);
return '#container_' + sanitizedId + '_type_incoming';
}
var sanitizedId = id.replace(/[!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~]/g, "\\$&");
return '#container_' + sanitizedId + '_type_incoming';
},
switchVideoToId: function(id) {
var videoSpeakingElement = $('#video-speaking');
@ -171,10 +161,10 @@ var spreedMappingTable = [];
latestSpeakerId = id;
},
add: function(id) {
// if no connection is established yet
if(id.length < 5) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
}
var sanitizedId = OCA.SpreedMe.speakers.getContainerId(id);
spreedListofSpeakers[sanitizedId] = (new Date()).getTime();
@ -187,6 +177,10 @@ var spreedMappingTable = [];
OCA.SpreedMe.speakers.switchVideoToId(id);
},
remove: function(id) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
}
var sanitizedId = OCA.SpreedMe.speakers.getContainerId(id);
spreedListofSpeakers[sanitizedId] = -1;
@ -205,6 +199,9 @@ var spreedMappingTable = [];
continue;
}
// skip non-string ids
if (!(typeof currentId === 'string' || currentId instanceof String)) continue;
var currentTime = spreedListofSpeakers[currentId];
if (currentTime > mostRecentTime) {
mostRecentTime = currentTime;

Loading…
Cancel
Save