diff --git a/files/helpers/media.py b/files/helpers/media.py index 6ab4897f3..c1aa58206 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -25,7 +25,7 @@ def process_files(): elif file.content_type.startswith('audio/'): body += f"\n\n{process_audio(file)}" else: - body += f"\n\n{process_other(file)}" + abort(415) return body diff --git a/files/routes/comments.py b/files/routes/comments.py index b41df7836..736afd9bc 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -297,7 +297,7 @@ def api_comment(v): elif file.content_type.startswith('audio/'): body += f"\n\n{process_audio(file)}" else: - body += f"\n\n{process_other(file)}" + abort(415) body = body.strip() diff --git a/files/routes/errors.py b/files/routes/errors.py index 40e73cc11..23b2ad7b5 100644 --- a/files/routes/errors.py +++ b/files/routes/errors.py @@ -51,6 +51,11 @@ def error_413(e): return {"error": "Max image/audio size is 8 MB (16 MB for paypigs)"}, 413 else: return render_template('errors/413.html', err=True), 413 +@app.errorhandler(415) +def error_415(e): + if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "Please upload only Image, Video, or Audio files!"}, 415 + else: return render_template('errors/415.html', err=True), 415 + @app.errorhandler(418) def error_418(e): if request.headers.get("Authorization") or request.headers.get("xhr"): diff --git a/files/routes/posts.py b/files/routes/posts.py index 528d07a18..8ef074084 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1068,7 +1068,7 @@ def submit_post(v, sub=None): elif file.content_type.startswith('audio/'): post.url = process_audio(file) else: - post.url = process_other(file) + abort(415) if not post.thumburl and post.url: gevent.spawn(thumbnail_thread, post.id) diff --git a/files/templates/comments.html b/files/templates/comments.html index 70ad02127..62729435f 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -329,7 +329,7 @@ Save Edit @@ -581,7 +581,7 @@ Comment @@ -620,7 +620,7 @@ {% if c.sentto == 2 %} {% endif %} diff --git a/files/templates/contact.html b/files/templates/contact.html index 8f7e441f6..48d9eb37b 100644 --- a/files/templates/contact.html +++ b/files/templates/contact.html @@ -36,7 +36,7 @@ diff --git a/files/templates/errors/415.html b/files/templates/errors/415.html new file mode 100644 index 000000000..0139fd86d --- /dev/null +++ b/files/templates/errors/415.html @@ -0,0 +1,20 @@ +{% extends "default.html" %} + +{% block title %} +
Please upload only Image, Video, or Audio files!
+