Skip to content

Commit

Permalink
Refactor request_contents_processor() to expose only data we use
Browse files Browse the repository at this point in the history
instead of the entire request contents. Otherwise this leads to
traceback recursion in edge cases, for example when Kiwi TCMS is
handling an error!
  • Loading branch information
atodorov committed Jan 17, 2025
1 parent ccf3f5f commit 57e62b2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions tcms/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tcms/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% block head %}{% endblock %}
</head>
<body id="{% block page_id %}{% endblock %}" class="{% block body_class %}{% endblock %}">
{% if not REQUEST_CONTENTS.nonav %}
{% if not REQUEST__NONAV %}
{% include 'navbar.html' %}
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion tcms/templates/include/ads.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if not REQUEST_CONTENTS.nonav %}
{% if not REQUEST__NONAV %}
<script async src="https://media.ethicalads.io/media/client/ethicalads.min.js"></script>
<div data-ea-publisher="kiwitcms-container" data-ea-type="text" data-ea-style="fixedfooter"></div>
{% endif %}
2 changes: 1 addition & 1 deletion tcms/templates/registration/password_reset_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="col-sm-7 col-md-6 col-lg-5 login">
<form class="form-horizontal" role="form" action="{% url "tcms-password_reset" %}" method="POST">
{% csrf_token %}
<input type="hidden" name="next" value="{{ REQUEST_CONTENTS.next }}" />
<input type="hidden" name="next" value="{{ REQUEST__NEXT }}" />

<div class="form-group">
{{ form.email.errors }}
Expand Down
2 changes: 1 addition & 1 deletion tcms/testcases/templates/testcases/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
</thead>
</table>

{% if REQUEST_CONTENTS.allow_select %}
{% if REQUEST__ALLOW_SELECT %}
<div class="form-group">
<button id="select-btn" type="submit" class="btn btn-primary">{% trans "Select" %}</button>
</div>
Expand Down

0 comments on commit 57e62b2

Please sign in to comment.