Opened 2 years ago

Closed 2 years ago

#33976 closed Bug (invalid)

HTTP_HOST does not allow an ipv6 not enclosed in []

Reported by: Eric Burghard Owned by: nobody
Component: Core (URLs) Version: 3.2
Severity: Normal Keywords: ipv6
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Eric Burghard)

Hi,

If I'm not mistaken, brackets are optional for an ipv6 address without port number. The problem is that it confuses django.

Invalid HTTP_HOST header: '2001:x:y:z:0:0:0:1'. The domain name provided is not valid according to RFC 1034/1035.

which can be fixed by changing django.http.request.host_validation_re to _lazy_re_compile(r"[a-zA-z0-9.:]*")

but it also triggers an exception with asgi.py

2022/09/02 07:57:10 [alert] 422#422 [unit] Python failed to call 'loop.call_soon'
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/base_events.py", line 750, in call_soon
    self._check_closed()
ValueError: invalid literal for int() with base 10: 'x:y:z:0:0:0:1'
2022/09/02 07:57:25 [alert] 422#422 [unit] #23: Python failed to create 'client' pair

Change History (3)

comment:1 by Eric Burghard, 2 years ago

Description: modified (diff)

comment:2 by Eric Burghard, 2 years ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 2 years ago

Resolution: invalid
Status: newclosed

As far as I'm aware, brackets are mandatory in the URI scheme for IPv6, see RFC3986:

      IP-literal = "[" ( IPv6address / IPvFuture  ) "]"
Note: See TracTickets for help on using tickets.
Back to Top