From dcbaf3204ef2abb501f7cfd0442862f3397bdea7 Mon Sep 17 00:00:00 2001 From: Eli Jones Date: Wed, 21 Aug 2024 07:36:35 -0400 Subject: [PATCH] [staged-updates] normalize whitespace on study creation. --- endpoints/study_endpoints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/endpoints/study_endpoints.py b/endpoints/study_endpoints.py index 9f23ba9aa..b35517f21 100644 --- a/endpoints/study_endpoints.py +++ b/endpoints/study_endpoints.py @@ -1,4 +1,5 @@ import json +import re from io import BytesIO import bleach @@ -225,6 +226,9 @@ def create_study(request: ResearcherRequest): messages.error(request, 'the study name you provided was too long and was rejected, please try again.') return redirect('/create_study') + # normalize all sequences of whitespace to a single space + name = re.sub("\s", " ", name) + if escape(name) != name: if not RUNNING_TEST_OR_FROM_A_SHELL: with make_error_sentry(SentryTypes.elastic_beanstalk):