mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Block HTML content in posts content
This commit is contained in:
		@@ -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 => {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -241,3 +241,34 @@ 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;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user