﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27181	"Sites framework does not normalize domains with trailing ""."""	Ran Benita	nobody	"I have a Django project which uses the sites framework. The site is picked by the {{{Host}}} and not by setting {{{SITE_ID}}}. Suppose one of the domains is ""mysite.com"". In DNS, this is equivalent to ""mysite.com."" (note the trailing dot). The nginx webserver, uwsgi, and Django's own {{{ALLOWED_HOSTS}}} accept ""mysite.com."" where ""mysite.com"" is specified. For example, the {{{validate_host()}}} function in http/request.py has this line:

{{{
host = host[:-1] if host.endswith('.') else host
}}}

which strips the trailing dot if it exists, before matching (this code is not ideal BTW, I think it will not work as intended if the host has a port).

However, the sites framework (in contrib/sites/models.py, {{{SiteManager._get_site_by_request}}}) fails to match in this case. This causes 500 when {{{get_current_site()}}} is called whenever a user requests some URL like ""http://mysite.com./"".

It would be nice if the sites framework was fixed to match trailing dot as well, similar to how https://code.djangoproject.com/ticket/24834 was fixed to deal with a {{{Host}}} like ""mysite.com:80""."	Bug	closed	contrib.sites	dev	Normal	fixed		zbigniew@…	Accepted	1	0	0	0	0	0
