From 57e62b21e22269a6af5bd6fe2735a02b4a28537c Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Fri, 17 Jan 2025 13:12:02 +0200 Subject: [PATCH] Refactor request_contents_processor() to expose only data we use instead of the entire request contents. Otherwise this leads to traceback recursion in edge cases, for example when Kiwi TCMS is handling an error! --- tcms/core/context_processors.py | 9 +++++++-- tcms/templates/base.html | 2 +- tcms/templates/include/ads.html | 2 +- tcms/templates/registration/password_reset_form.html | 2 +- tcms/testcases/templates/testcases/search.html | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tcms/core/context_processors.py b/tcms/core/context_processors.py index c92a96c4ea..f2b769b502 100644 --- a/tcms/core/context_processors.py +++ b/tcms/core/context_processors.py @@ -5,9 +5,14 @@ def request_contents_processor(request): """ - Django request contents RequestContext Handler + Exposes only values that we need, not everything! """ - return {"REQUEST_CONTENTS": request.GET or request.POST} + data = request.GET or request.POST + return { + "REQUEST__ALLOW_SELECT": data.get("allow_select"), + "REQUEST__NEXT": data.get("next", ""), + "REQUEST__NONAV": data.get("nonav"), + } def settings_processor(_request): diff --git a/tcms/templates/base.html b/tcms/templates/base.html index 6dbdabe9d4..ccaabb5856 100644 --- a/tcms/templates/base.html +++ b/tcms/templates/base.html @@ -32,7 +32,7 @@ {% block head %}{% endblock %} - {% if not REQUEST_CONTENTS.nonav %} + {% if not REQUEST__NONAV %} {% include 'navbar.html' %} {% endif %} diff --git a/tcms/templates/include/ads.html b/tcms/templates/include/ads.html index 4028c22c68..7c4a4d2849 100644 --- a/tcms/templates/include/ads.html +++ b/tcms/templates/include/ads.html @@ -1,4 +1,4 @@ -{% if not REQUEST_CONTENTS.nonav %} +{% if not REQUEST__NONAV %}
{% endif %} diff --git a/tcms/templates/registration/password_reset_form.html b/tcms/templates/registration/password_reset_form.html index f61073a111..4403f9a5aa 100644 --- a/tcms/templates/registration/password_reset_form.html +++ b/tcms/templates/registration/password_reset_form.html @@ -9,7 +9,7 @@
{% csrf_token %} - +
{{ form.email.errors }} diff --git a/tcms/testcases/templates/testcases/search.html b/tcms/testcases/templates/testcases/search.html index 1ae8e7598c..e1756073e5 100644 --- a/tcms/testcases/templates/testcases/search.html +++ b/tcms/testcases/templates/testcases/search.html @@ -165,7 +165,7 @@ - {% if REQUEST_CONTENTS.allow_select %} + {% if REQUEST__ALLOW_SELECT %}