mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +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,
|
appendTo: cardContent,
|
||||||
type: "div",
|
type: "div",
|
||||||
class: "post-content",
|
class: "post-content",
|
||||||
innerHTML: post.content
|
innerHTML: removeHtmlTags(post.content)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ function RefreshTabsVisibility(){
|
|||||||
var hash = location.href.toString().split("#")[1];
|
var hash = location.href.toString().split("#")[1];
|
||||||
|
|
||||||
if(!hash)
|
if(!hash)
|
||||||
return;
|
hash = "home";
|
||||||
|
|
||||||
document.querySelectorAll(".category").forEach(el => {
|
document.querySelectorAll(".category").forEach(el => {
|
||||||
|
|
||||||
|
@ -241,3 +241,34 @@ function userID() {
|
|||||||
function fileSizeToHuman(size) {
|
function fileSizeToHuman(size) {
|
||||||
return Math.round(size/(1000*1000)*1000)/1000 + "MB";
|
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