From 4bb33bb07450ea9b623877417c28e6489246f51c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 13 Apr 2020 09:07:28 +0100 Subject: [PATCH] Fixed #31459 -- Fixed handling invalid indentifiers in URL path conversion. This patch adjusted existing tests that used invalid identifiers. --- django/urls/resolvers.py | 2 +- tests/check_framework/test_urls.py | 2 +- .../urls/path_compatibility/contains_re_named_group.py | 2 +- tests/gis_tests/geoapp/urls.py | 2 +- tests/urlpatterns/tests.py | 10 +++++++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index b6b9d6fb2b..3c95e1d686 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -197,7 +197,7 @@ class RegexPattern(CheckURLMixin): _PATH_PARAMETER_COMPONENT_RE = _lazy_re_compile( - r'<(?:(?P[^>:]+):)?(?P\w+)>' + r'<(?:(?P[^>:]+):)?(?P[^>]+)>' ) diff --git a/tests/check_framework/test_urls.py b/tests/check_framework/test_urls.py index 217b5e7bad..f0c257bc77 100644 --- a/tests/check_framework/test_urls.py +++ b/tests/check_framework/test_urls.py @@ -143,7 +143,7 @@ class UpdatedToPathTests(SimpleTestCase): self.assertEqual(len(result), 1) warning = result[0] self.assertEqual(warning.id, '2_0.W001') - expected_msg = "Your URL pattern '(?P\\d+)' has a route" + expected_msg = "Your URL pattern '(?P\\d+)' has a route" self.assertIn(expected_msg, warning.msg) @override_settings(ROOT_URLCONF='check_framework.urls.path_compatibility.beginning_with_caret') diff --git a/tests/check_framework/urls/path_compatibility/contains_re_named_group.py b/tests/check_framework/urls/path_compatibility/contains_re_named_group.py index a99c79354e..bd849509f5 100644 --- a/tests/check_framework/urls/path_compatibility/contains_re_named_group.py +++ b/tests/check_framework/urls/path_compatibility/contains_re_named_group.py @@ -1,5 +1,5 @@ from django.urls import path urlpatterns = [ - path(r'(?P\d+)', lambda x: x), + path(r'(?P\d+)', lambda x: x), ] diff --git a/tests/gis_tests/geoapp/urls.py b/tests/gis_tests/geoapp/urls.py index 9635d8ddbf..8597387f82 100644 --- a/tests/gis_tests/geoapp/urls.py +++ b/tests/gis_tests/geoapp/urls.py @@ -20,7 +20,7 @@ urlpatterns += [ gis_sitemap_views.kml, name='django.contrib.gis.sitemaps.views.kml'), path( - 'sitemaps/kml/