Projet

Général

Profil

0001-middleware-improve-condition-to-automatically-determ.patch

Benjamin Dauvergne, 27 septembre 2017 14:37

Télécharger (1,41 ko)

Voir les différences:

Subject: [PATCH] middleware: improve condition to automatically determine a
 common domain (fixes #15548)

It works if:
- HTTP Host is a domain name and not an IP address (IPv6 address will not passe
  this test, they lack dots),
- domain contains at least three components.
 mellon/middleware.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
mellon/middleware.py
35 35
            # get the common domain or guess
36 36
            common_domain = app_settings.OPENED_SESSION_COOKIE_DOMAIN
37 37
            if not common_domain:
38
                host = request.get_host()
39
                # accept automatic common domain selection if domain has at least three components
40
                # and is not an IP address
41
                if not host.count('.') > 1 or host.replace('.', '').isdigit():
42
                    return
38 43
                common_domain = request.get_host().split('.', 1)[1]
39
                assert '.' in common_domain  # if domain is xxx.com explode !
40 44
            params = {
41 45
                'next': request.build_absolute_uri(),
42 46
                'passive': '',
43
-