From a49c36268bf814751ff93096dcf79de762c74a1b Mon Sep 17 00:00:00 2001
From: neptune
Date: Sat, 17 Dec 2022 05:20:44 -0300
Subject: Quitar HTML en basural
---
cgi/formatting.py | 7 +++++++
cgi/post.py | 2 ++
2 files changed, 9 insertions(+)
diff --git a/cgi/formatting.py b/cgi/formatting.py
index 33495a3..cb512ab 100644
--- a/cgi/formatting.py
+++ b/cgi/formatting.py
@@ -336,6 +336,13 @@ def close_html(message):
return message[:l]
+def remove_html(message):
+ string = message.replace("
", "\n")
+ string = re.sub(r"<.*?>", '', string)
+ string = string.replace("\n", "
")
+ return string
+
+
def sanitize_html(message, decode=True):
"""
Clean the code and allow only a few safe tags.
diff --git a/cgi/post.py b/cgi/post.py
index 264f207..b80b17d 100644
--- a/cgi/post.py
+++ b/cgi/post.py
@@ -1117,6 +1117,8 @@ def regenerateNews():
def regenerateTrash():
posts = FetchAll("SELECT posts.id AS id, timestamp_formatted, posts.message AS message, boards.name AS board FROM `posts` INNER JOIN `boards` ON boardid = boards.id WHERE IS_DELETED = 2 ORDER BY `timestamp` DESC")
+ for i in range(len(posts)):
+ posts[i]["message"] = formatting.remove_html(posts[i]["message"])
template_values = {'posts': posts}
page_rendered = renderTemplate('trash.html', template_values)
--
cgit v1.2.1-18-gbd029