summaryrefslogtreecommitdiff
path: root/django/urls/resolvers.py
diff options
context:
space:
mode:
authorTim Park <timpark0807@gmail.com>2020-08-29 12:17:58 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-09-02 10:24:14 +0200
commitece18207cbb64dd89014e279ac636a6c9829828e (patch)
tree0aeee2b07eb0eaab4bce5f93f4db77f990c56802 /django/urls/resolvers.py
parenta6291394256aa758d74eec9ce0cfae8aea6475f2 (diff)
Fixed #31858 -- Reallowed whitespaces in URL paths outside of parameters.
Regression in 22394bd3a18a7d9a8957a0b431f8ae4e5ca03a8c. Thanks David Smith for the review.
Diffstat (limited to 'django/urls/resolvers.py')
-rw-r--r--django/urls/resolvers.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
index 9f4d84d5a2..5e3e6dea16 100644
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -208,8 +208,6 @@ def _route_to_regex(route, is_endpoint=False):
For example, 'foo/<int:pk>' returns '^foo\\/(?P<pk>[0-9]+)'
and {'pk': <django.urls.converters.IntConverter>}.
"""
- if not set(route).isdisjoint(string.whitespace):
- raise ImproperlyConfigured("URL route '%s' cannot contain whitespace." % route)
original_route = route
parts = ['^']
converters = {}
@@ -218,6 +216,11 @@ def _route_to_regex(route, is_endpoint=False):
if not match:
parts.append(re.escape(route))
break
+ elif not set(match.group()).isdisjoint(string.whitespace):
+ raise ImproperlyConfigured(
+ "URL route '%s' cannot contain whitespace in angle brackets "
+ "<…>." % original_route
+ )
parts.append(re.escape(route[:match.start()]))
route = route[match.end():]
parameter = match['parameter']