From ab726bc7204466528515dd1b7d40621815e01626 Mon Sep 17 00:00:00 2001 From: mst Date: Fri, 28 Feb 2025 07:17:39 +0300 Subject: [PATCH] no spaces-only questions --- app.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index ee084d8..de8ee63 100644 --- a/app.py +++ b/app.py @@ -587,10 +587,12 @@ def addQuestion(): question = request.form.get('question', '') cw = request.form.get('cw', '') - if not question: - abort(400, "Question field must not be empty") + question_normalized = unicodedata.normalize('NFKC', question).replace("⠀", "").strip() + + if not question or not question_normalized: + abort(400, _("Question field must not be empty")) if len(question) > int(cfg['charLimit']) or len(from_who) > int(cfg['charLimit']): - abort(400, "Question exceeds the character limit") + abort(400, _("Question exceeds the character limit")) return_val = func.addQuestion(from_who, question, cw) app.logger.debug("[CatAsk/API/add_question] finished question flow") return return_val[0]