diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py
index 17d1bc03bf..9526ddcf45 100644
--- a/files/helpers/sanitize.py
+++ b/files/helpers/sanitize.py
@@ -129,17 +129,17 @@ def sanitize(sanitized, noimages=False):
if site not in tag["src"] and not tag["src"].startswith('/'): tag["rel"] = "nofollow noopener noreferrer"
tag["class"] = "in-comment-image"
+ tag["width"] = "150"
+ tag["height"] = "150"
tag["loading"] = "lazy"
- # tag["data-src"] = tag["src"]
- # tag["src"] = "/assets/images/loading.webp"
+ tag["data-src"] = tag["src"]
+ tag["src"] = "/assets/images/loading.webp"
link = soup.new_tag("a")
- # link["href"] = tag["data-src"]
- link["href"] = tag["src"]
+ link["href"] = tag["data-src"]
if site not in link["href"] and not link["href"].startswith('/'): link["rel"] = "nofollow noopener noreferrer"
link["target"] = "_blank"
- # link["onclick"] = f"expandDesktopImage('{tag['data-src']}');"
- link["onclick"] = f"expandDesktopImage('{tag['src']}');"
+ link["onclick"] = f"expandDesktopImage('{tag['data-src']}');"
link["data-bs-toggle"] = "modal"
link["data-bs-target"] = "#expandImageModal"
@@ -174,13 +174,13 @@ def sanitize(sanitized, noimages=False):
for i in re.finditer('(?', sanitized)
+ sanitized = re.sub(f'(?', sanitized)
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
else: session["favorite_emojis"][emoji] = 1
elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'):
- sanitized = re.sub(f'(?', sanitized)
+ sanitized = re.sub(f'(?', sanitized)
if emoji in session["favorite_emojis"]: session["favorite_emojis"][emoji] += 1
else: session["favorite_emojis"][emoji] = 1
@@ -211,28 +211,36 @@ def sanitize(sanitized, noimages=False):
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("https://m.wikipedia", "https://wikipedia").replace("https://m.youtube", "https://youtube")
+ if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
- for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=.*?)', sanitized):
+ for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))', sanitized):
url = i.group(1)
+ yt_id = i.group(2).split('&')[0]
replacing = f'{url}'
- url = url.replace("watch?v=", "embed/").replace("&t", "?start").replace("?t", "?start")
- url = re.sub('(\?start=([0-9]*?))s', r'\1', url)
- htmlsource = f''
+
+ params = parse_qs(urlparse(url).query)
+ t = params.get('t', params.get('start', [0]))[0]
+ if isinstance(t, str): t = t.replace('s','')
+
+ htmlsource = f'
(https:.*?\.mp4)
', sanitized): - sanitized = sanitized.replace(i.group(0), f'') + sanitized = sanitized.replace(i.group(0), f'
') for i in re.finditer('{url}' - htmlsource = f'' + htmlsource = f'' sanitized = sanitized.replace(replacing, htmlsource) for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]: @@ -258,7 +266,7 @@ def filter_title(title): if emoji.startswith("!"): emoji = emoji[1:] if path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): - title = re.sub(f'(?', title) + title = re.sub(f'(?', title) elif path.isfile(f'./files/assets/images/emojis/{emoji}.webp'): title = re.sub(f'(?', title) diff --git a/files/templates/authforms.html b/files/templates/authforms.html index 5d0ba56177..ab3848b48d 100644 --- a/files/templates/authforms.html +++ b/files/templates/authforms.html @@ -15,11 +15,11 @@ {% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} diff --git a/files/templates/comments.html b/files/templates/comments.html index d17652fb7d..08ca7997a4 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -749,7 +749,7 @@ {% if v %} - + {% endif %} diff --git a/files/templates/default.html b/files/templates/default.html index 4a723dc1d3..950e31e80a 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -3,18 +3,16 @@
{% if v %} - + {% if v.agendaposter %}{% elif v.css %}{% endif %} {% else %} - + {% endif %} - - @@ -355,8 +353,11 @@ {% endif %} + + + -