Atualizar app/app.py
This commit is contained in:
+10
-6
@@ -775,10 +775,9 @@ def export_md(cid):
|
||||
return Response(md, mimetype="text/markdown")
|
||||
|
||||
|
||||
|
||||
@app.route("/api/file/<file_id>")
|
||||
@app.route("/api/file/<file_id>/<filename>")
|
||||
@login_required
|
||||
def get_file(file_id):
|
||||
def get_file(file_id, filename):
|
||||
email = session["user"]["email"] if app.config["AUTH_MODE"] == "oauth" else session["db_user"]["email"]
|
||||
|
||||
db = SessionLocal()
|
||||
@@ -788,10 +787,15 @@ def get_file(file_id):
|
||||
if not f:
|
||||
return jsonify({"erro": "Arquivo não encontrado."}), 404
|
||||
|
||||
return send_file(f.path)
|
||||
|
||||
|
||||
# Segurança: impedir que o usuário tente baixar outro nome
|
||||
if filename != f.original_name:
|
||||
return jsonify({"erro": "Nome de arquivo inválido."}), 400
|
||||
|
||||
return send_file(
|
||||
f.path,
|
||||
as_attachment=True,
|
||||
download_name=f.original_name
|
||||
)
|
||||
|
||||
|
||||
from weasyprint import HTML
|
||||
|
||||
Reference in New Issue
Block a user