#27181: Sites framework does not normalize domains with trailing "."
-------------------------------+--------------------
     Reporter:  bluetech       |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  contrib.sites  |    Version:  1.10
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 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".

--
Ticket URL: <https://code.djangoproject.com/ticket/27181>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.53e6a3238027e9b8b7a2c7ac9f6d0b05%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to