diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index c2e9c29245..1d96d63576 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -210,7 +210,10 @@ def sanitize(sanitized, noimages=False): start = '<s>' end = '</s>' - if not session.get("favorite_emojis"): session["favorite_emojis"] = {} + try: + if not session.get("favorite_emojis"): session["favorite_emojis"] = {} + except Exception: + pass if start in sanitized and end in sanitized and start in sanitized.split(end)[0] and end in sanitized.split(start)[1]: sanitized = sanitized.replace(start, '').replace(end, '') @@ -218,15 +221,21 @@ def sanitize(sanitized, noimages=False): if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'): sanitized = sanitized.replace(f'
:{i.group(1)}:
', f'')
- if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
- else: session["favorite_emojis"][i.group(1)] = 1
+ try:
+ if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
+ else: session["favorite_emojis"][i.group(1)] = 1
+ except Exception:
+ pass
for i in re.finditer(':([^ ]{1,30}?):', sanitized):
if path.isfile(f'./files/assets/images/emojis/{i.group(1)}.gif'):
sanitized = sanitized.replace(f':{i.group(1)}:', f'
')
- if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
- else: session["favorite_emojis"][i.group(1)] = 1
+ try:
+ if i.group(1) in session["favorite_emojis"]: session["favorite_emojis"][i.group(1)] += 1
+ else: session["favorite_emojis"][i.group(1)] = 1
+ except Exception:
+ pass
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.", "https://").replace("https://m.", "https://")
diff --git a/files/routes/posts.py b/files/routes/posts.py
index 597127a983..e0b2702307 100644
--- a/files/routes/posts.py
+++ b/files/routes/posts.py
@@ -3,6 +3,7 @@ from urllib.parse import urlparse
import mistletoe
import urllib.parse
import gevent
+import traceback
from files.helpers.wrappers import *
from files.helpers.sanitize import *
@@ -565,7 +566,9 @@ def check_processing_thread(v, post, link, db):
elif status == 'failed':
print(f"video upload for post {post.id} failed")
break
- except Exception:
+ except Exception as e:
+ traceback.print_exc()
+ print("retard. aborting thread")
break