Fixed security breach in conversations system

This commit is contained in:
Pierre 2017-07-04 21:13:02 +02:00
parent 798e43d446
commit 6251d47ca0
2 changed files with 28 additions and 1 deletions

View File

@ -289,4 +289,31 @@ function checkString(value){
//Success, the string seems to be valid
return true;
}
/**
* Remove HTML carachters : < and >
*
* @param {String} input The string to change
* @return {String} The updated string
*/
function removeHtmlTags(input){
//Prepare update
var output = input;
//Replace opening braces
while(output.includes("<")){
//Replace an occurence
output = output.replace("<", "&lt;");
}
//Replace closing braces
while(output.includes(">")){
//Replace an occurence
output = output.replace(">", "&gt;");
}
//Return result
return output;
}

View File

@ -789,7 +789,7 @@ ComunicWeb.components.conversations.chatWindows = {
var textMessage = createElem2({
appendTo: messageTargetElem,
type: "span",
innerHTML: messageInfos.message,
innerHTML: removeHtmlTags(messageInfos.message), //Remove HTML tags
});
//Check if an image has to be added