mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 09:58:51 +00:00
Block HTML content in posts content
This commit is contained in:
parent
30353c5277
commit
35d1e6a8b1
@ -106,7 +106,7 @@ function ApplyPosts(){
|
||||
appendTo: cardContent,
|
||||
type: "div",
|
||||
class: "post-content",
|
||||
innerHTML: post.content
|
||||
innerHTML: removeHtmlTags(post.content)
|
||||
});
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ function RefreshTabsVisibility(){
|
||||
var hash = location.href.toString().split("#")[1];
|
||||
|
||||
if(!hash)
|
||||
return;
|
||||
hash = "home";
|
||||
|
||||
document.querySelectorAll(".category").forEach(el => {
|
||||
|
||||
|
@ -240,4 +240,35 @@ function userID() {
|
||||
*/
|
||||
function fileSizeToHuman(size) {
|
||||
return Math.round(size/(1000*1000)*1000)/1000 + "MB";
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HTML carachters : < and >
|
||||
*
|
||||
* @param {String} input The string to change
|
||||
* @return {String} The updated string
|
||||
*/
|
||||
function removeHtmlTags(input){
|
||||
|
||||
//Check if input string is empty
|
||||
if(input == null || typeof input !== "string")
|
||||
return "";
|
||||
|
||||
//Prepare update
|
||||
var output = input;
|
||||
|
||||
//Replace opening braces
|
||||
while(output.includes("<")){
|
||||
//Replace an occurence
|
||||
output = output.replace("<", "<");
|
||||
}
|
||||
|
||||
//Replace closing braces
|
||||
while(output.includes(">")){
|
||||
//Replace an occurence
|
||||
output = output.replace(">", ">");
|
||||
}
|
||||
|
||||
//Return result
|
||||
return output;
|
||||
}
|
Loading…
Reference in New Issue
Block a user