[config] Lowercase the FQDN we get from the OS (closes #5040345)
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 11 Mar 2015 15:17:25 +0100
changeset 10224 996cf2c0ec99
parent 10223 fbb370195199
child 10225 176918710c44
[config] Lowercase the FQDN we get from the OS (closes #5040345) Browsers convert the host name part of URLs to lowercase. This has the unfortunate effect of triggering various CORS error messages in CubicWeb (because the Origin: header will contain lowercase letters). As per RFC 4343, host name comparison should be case-insensitive. So let's put it in lowercase when we grab it from the host system. If admins put uppercase letters in "host" or "base-url" in their all-in-one.conf, then it's their fault.
etwist/twconfig.py
--- a/etwist/twconfig.py	Tue Mar 10 11:52:04 2015 +0100
+++ b/etwist/twconfig.py	Wed Mar 11 15:17:25 2015 +0100
@@ -103,7 +103,7 @@
 
     def default_base_url(self):
         from socket import getfqdn
-        return 'http://%s:%s/' % (self['host'] or getfqdn(), self['port'] or 8080)
+        return 'http://%s:%s/' % (self['host'] or getfqdn().lower(), self['port'] or 8080)
 
 
 try: