1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #27181 -- Allowed contrib.sites to match domains with trailing ".".

This commit is contained in:
Anton Samarchyan
2016-11-29 18:17:10 -05:00
committed by Tim Graham
parent 95627cb0aa
commit 05d2c5a66d
4 changed files with 23 additions and 7 deletions

View File

@@ -93,6 +93,19 @@ class SitesFrameworkTests(TestCase):
site = get_current_site(request)
self.assertEqual(site.name, "example.com")
@override_settings(SITE_ID='', ALLOWED_HOSTS=['example.com'])
def test_get_current_site_host_with_trailing_dot(self):
"""
The site is matched if the name in the request has a trailing dot.
"""
request = HttpRequest()
request.META = {
'SERVER_NAME': 'example.com.',
'SERVER_PORT': '80',
}
site = get_current_site(request)
self.assertEqual(site.name, 'example.com')
@override_settings(SITE_ID='', ALLOWED_HOSTS=['example.com', 'example.net'])
def test_get_current_site_no_site_id_and_handle_port_fallback(self):
request = HttpRequest()