aboutsummaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
authorLibravatar neptune 2022-12-17 05:20:44 -0300
committerLibravatar Choom 2022-12-17 05:51:28 -0300
commita49c36268bf814751ff93096dcf79de762c74a1b (patch)
tree264745171acd08a193cca1984aa81c4b03343d4c /cgi
parent8f22787c5bb5fdd45c5f6c822c0a4ef95a3a31b0 (diff)
downloadweabot-a49c36268bf814751ff93096dcf79de762c74a1b.tar.gz
weabot-a49c36268bf814751ff93096dcf79de762c74a1b.tar.xz
weabot-a49c36268bf814751ff93096dcf79de762c74a1b.zip
Quitar HTML en basural
Diffstat (limited to 'cgi')
-rw-r--r--cgi/formatting.py7
-rw-r--r--cgi/post.py2
2 files changed, 9 insertions, 0 deletions
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("<br />", "\n")
+ string = re.sub(r"<.*?>", '', string)
+ string = string.replace("\n", "<br />")
+ 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)