diff --git a/db.py b/db.py index 61a9a749..7c326dba 100644 --- a/db.py +++ b/db.py @@ -20,6 +20,7 @@ from telegram import User as TelegramUser import loldata from dirty import Dirty import query_discord_music +from flask import escape # Init the config reader import configparser @@ -685,6 +686,9 @@ class Diario(Base): def __str__(self): return f"{self.id} - {self.timestamp} - {self.author}: {self.text}" + def to_html(self): + return str(escape(self.text)).replace("\n", "
") + @staticmethod def import_from_json(file): import json diff --git a/templates/components/diarioentry.html b/templates/components/diarioentry.html index aba067b7..caa95470 100644 --- a/templates/components/diarioentry.html +++ b/templates/components/diarioentry.html @@ -1,7 +1,7 @@

- {{ entry.text }} + {{ entry.to_html() | safe }}

— {% if entry.author is not none %}{{ entry.author.royal.username }}{% else %}Anonimo{% endif %}, {{ entry.timestamp.strftime('%Y-%m-%d %H:%M:%S %Z') }} {% if entry.saver is not none and entry.saver != entry.author %}(salvato da {{ entry.saver.royal.username }}){% endif %}