summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-04-29 14:35:11 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-30 08:05:42 +0200
commit8bcb00858e0ddec79cc96669c238d29c30d7effb (patch)
treecba5b4df1cd188543adc523ccedfead1ac26075d /django
parentca34db46504fca1221e27f6ab13734dfdfde6e1c (diff)
Fixed #32698 -- Moved HttpRequest.get_raw_uri() to ExceptionReporter._get_raw_insecure_uri().
Diffstat (limited to 'django')
-rw-r--r--django/http/request.py11
-rw-r--r--django/views/debug.py13
-rw-r--r--django/views/templates/technical_500.html4
-rw-r--r--django/views/templates/technical_500.txt2
4 files changed, 16 insertions, 14 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 79fc8350fd..c7922e59e9 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -180,17 +180,6 @@ class HttpRequest:
raise
return value
- def get_raw_uri(self):
- """
- Return an absolute URI from variables available in this request. Skip
- allowed hosts protection, so may return insecure URI.
- """
- return '{scheme}://{host}{path}'.format(
- scheme=self.scheme,
- host=self._get_raw_host(),
- path=self.get_full_path(),
- )
-
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
diff --git a/django/views/debug.py b/django/views/debug.py
index 67bb5de20b..16c9ad7fc8 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -274,6 +274,17 @@ class ExceptionReporter:
self.template_does_not_exist = False
self.postmortem = None
+ def _get_raw_insecure_uri(self):
+ """
+ Return an absolute URI from variables available in this request. Skip
+ allowed hosts protection, so may return insecure URI.
+ """
+ return '{scheme}://{host}{path}'.format(
+ scheme=self.request.scheme,
+ host=self.request._get_raw_host(),
+ path=self.request.get_full_path(),
+ )
+
def get_traceback_data(self):
"""Return a dictionary containing traceback information."""
if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
@@ -337,6 +348,8 @@ class ExceptionReporter:
c['request_GET_items'] = self.request.GET.items()
c['request_FILES_items'] = self.request.FILES.items()
c['request_COOKIES_items'] = self.request.COOKIES.items()
+ c['request_insecure_uri'] = self._get_raw_insecure_uri()
+
# Check whether exception info is available
if self.exc_type:
c['exception_type'] = self.exc_type.__name__
diff --git a/django/views/templates/technical_500.html b/django/views/templates/technical_500.html
index b5ea1a78a7..7683896c56 100644
--- a/django/views/templates/technical_500.html
+++ b/django/views/templates/technical_500.html
@@ -108,7 +108,7 @@
</tr>
<tr>
<th>Request URL:</th>
- <td>{{ request.get_raw_uri }}</td>
+ <td>{{ request_insecure_uri }}</td>
</tr>
{% endif %}
<tr>
@@ -289,7 +289,7 @@ Environment:
{% if request %}
Request Method: {{ request.META.REQUEST_METHOD }}
-Request URL: {{ request.get_raw_uri }}
+Request URL: {{ request_insecure_uri }}
{% endif %}
Django Version: {{ django_version_info }}
Python Version: {{ sys_version_info }}
diff --git a/django/views/templates/technical_500.txt b/django/views/templates/technical_500.txt
index 551413aab7..5c86a3139f 100644
--- a/django/views/templates/technical_500.txt
+++ b/django/views/templates/technical_500.txt
@@ -2,7 +2,7 @@
{% firstof exception_value 'No exception message supplied' %}
{% if request %}
Request Method: {{ request.META.REQUEST_METHOD }}
-Request URL: {{ request.get_raw_uri }}{% endif %}
+Request URL: {{ request_insecure_uri }}{% endif %}
Django Version: {{ django_version_info }}
Python Executable: {{ sys_executable }}
Python Version: {{ sys_version_info }}