From c2a2971467cd2c3185202ffb9adbc89c6e17ed10 Mon Sep 17 00:00:00 2001 From: "theo@manjaro" Date: Wed, 15 Jun 2022 20:01:22 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9t=C3=A9ction=20d'identifiants=20de=20d?= =?UTF-8?q?=C3=A9partement=20invalides?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app.py b/app.py index e221681..638bf74 100644 --- a/app.py +++ b/app.py @@ -164,6 +164,15 @@ def free_rooms() : # Récupération de la liste des départements : dept_filen = "data/dept_list.txt" dept_list = ro.get_depts(dept_filen) + # Vérifie qu'il n'y a pas de mauvais départements demandés + for d in dident_list: + try: + int(d) + except: + return render_template("error.html",error="Identifiant de département invalide !", **GLOBAL_CONTEXT) + if int(d)<0 or int(d)>=len(dept_list): + return render_template("error.html",error="Identifiant de département invalide !", **GLOBAL_CONTEXT) + dident_list.sort() # Récupération des départements choisis à partir des données du formulaire : i = 0