This commit is contained in:
2026-01-02 20:00:10 +00:00
parent c32caaf052
commit 0fb7bc6f9e
7 changed files with 43 additions and 10 deletions

View File

@@ -120,10 +120,12 @@ def setup_shared_routes(app):
if not file.filename.endswith('.mp3'):
return jsonify({"success": False, "error": "Only MP3 files are allowed"}), 400
# Sanitize filename
# Sanitize filename (keep extension)
import re
filename = re.sub(r'[^\w\s-]', '', file.filename)
filename = re.sub(r'[-\s]+', '-', filename)
name_without_ext = os.path.splitext(file.filename)[0]
name_without_ext = re.sub(r'[^\w\s-]', '', name_without_ext)
name_without_ext = re.sub(r'[-\s]+', '-', name_without_ext)
filename = f"{name_without_ext}.mp3"
filepath = os.path.join(MUSIC_FOLDER, filename)