[Django] #32537: RequestSite and IDN

14 views
Skip to first unread message

Django

unread,
Mar 11, 2021, 6:39:47 AM3/11/21
to django-...@googlegroups.com
#32537: RequestSite and IDN
--------------------------------------------+------------------------
Reporter: François Poulain | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
Without using django.contrib.sites, get_current_site reply a RequestSite
instance defining name and domain.

On a IDN setup, we are currently getting Punicode in the name due to the
init sequence:
{{{
def __init__(self, request):
self.domain = self.name = request.get_host()
}}}
IMHO a punicode version of the domain in not what I expect in the
{{{name}}} attribute.

I suggest that if the domains starts with {{{xn--}}} it should be tried to
set the name by decoding the domain from idna.

How do you think about it? (I may provide patch if you agree on the
behavior)

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

Django

unread,
Mar 11, 2021, 7:06:55 AM3/11/21
to django-...@googlegroups.com
#32537: RequestSite and IDN
----------------------------------+--------------------------------------

Reporter: François Poulain | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Description changed by François Poulain:

Old description:

> Without using django.contrib.sites, get_current_site reply a RequestSite
> instance defining name and domain.
>
> On a IDN setup, we are currently getting Punicode in the name due to the
> init sequence:
> {{{
> def __init__(self, request):
> self.domain = self.name = request.get_host()
> }}}
> IMHO a punicode version of the domain in not what I expect in the
> {{{name}}} attribute.
>
> I suggest that if the domains starts with {{{xn--}}} it should be tried
> to set the name by decoding the domain from idna.
>
> How do you think about it? (I may provide patch if you agree on the
> behavior)

New description:

Without using django.contrib.sites, get_current_site reply a RequestSite
instance defining name and domain.

On a IDN setup, we are currently getting Punicode in the name due to the
init sequence:
{{{
def __init__(self, request):
self.domain = self.name = request.get_host()
}}}
IMHO a punicode version of the domain in not what I expect in the
{{{name}}} attribute.

I suggest that if any part of the domains starts with {{{xn--}}} it should


be tried to set the name by decoding the domain from idna.

How do you think about it? (I may provide patch if you agree on the
behavior)

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32537#comment:1>

Django

unread,
Mar 12, 2021, 4:01:00 AM3/12/21
to django-...@googlegroups.com
#32537: RequestSite and IDN
----------------------------------+--------------------------------------
Reporter: François Poulain | Owner: nobody
Type: New feature | Status: closed
Component: contrib.sites | Version: 3.1
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo
* component: Uncategorized => contrib.sites
* type: Uncategorized => New feature


Comment:

This is a [https://docs.djangoproject.com/en/3.1/ref/contrib/sites
/#requestsite-objects documented] behavior:

> ''"Sets the name and domain attributes to the value of
**get_host**()."''

and [https://docs.djangoproject.com/en/3.1/ref/request-
response/#django.http.HttpRequest.get_host get_host()] ''"returns the
originating host of the request using information from the ..."''

Decoding punycodes would be backward incompatible and it's not clear to me
why a puncode in `name` is an issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/32537#comment:2>

Django

unread,
Mar 24, 2021, 12:44:24 PM3/24/21
to django-...@googlegroups.com
#32537: RequestSite and IDN
----------------------------------+--------------------------------------
Reporter: François Poulain | Owner: nobody
Type: New feature | Status: closed
Component: contrib.sites | Version: 3.1
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------

Comment (by François Poulain):

> This is a ​documented behavior

Ok, thanks for the link.

> it's not clear to me why a puncode in name is an issue

I thought it because the
[https://docs.djangoproject.com/en/3.1/ref/contrib/sites/#django.contrib.sites.models.Site
models.Site documentation] states that {{{name}}} is "A human-readable
“verbose” name for the website."

--
Ticket URL: <https://code.djangoproject.com/ticket/32537#comment:3>

Reply all
Reply to author
Forward
0 new messages