From d81ad2fd12e40c6d2cb4514958257ed36917f91c Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 17 Sep 2020 17:02:50 +0200 Subject: [PATCH] sanitize mailbox before creating: remove empty space --- app/api/views/mailbox.py | 2 +- app/dashboard/views/mailbox.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/views/mailbox.py b/app/api/views/mailbox.py index 4d112790..517148ac 100644 --- a/app/api/views/mailbox.py +++ b/app/api/views/mailbox.py @@ -30,7 +30,7 @@ def create_mailbox(): """ user = g.user - mailbox_email = request.get_json().get("email").lower().strip() + mailbox_email = request.get_json().get("email").lower().strip().replace(" ", "") if mailbox_already_used(mailbox_email, user): return jsonify(error=f"{mailbox_email} already used"), 400 diff --git a/app/dashboard/views/mailbox.py b/app/dashboard/views/mailbox.py index 6b0da7e3..a14333fa 100644 --- a/app/dashboard/views/mailbox.py +++ b/app/dashboard/views/mailbox.py @@ -82,7 +82,9 @@ def mailbox_route(): return redirect(url_for("dashboard.mailbox_route")) if new_mailbox_form.validate(): - mailbox_email = new_mailbox_form.email.data.lower().strip() + mailbox_email = ( + new_mailbox_form.email.data.lower().strip().replace(" ", "") + ) if mailbox_already_used(mailbox_email, current_user): flash(f"{mailbox_email} already used", "error")