Mercurial > libervia-web
diff libervia/server/pages.py @ 1168:ea0caa7b1bcc
pages (i18n): check presence of u"/" in locale:
if u"/" is present in local, a warning message is logged, and locale is ignored.
This is done because in some cases locale can be used with a path (e.g. if several localised version of a document are used).
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 12 Apr 2019 14:06:50 +0200 |
parents | 7d2e098ea3f4 |
children | 97e850e6fae9 |
line wrap: on
line diff
--- a/libervia/server/pages.py Fri Apr 12 13:58:02 2019 +0200 +++ b/libervia/server/pages.py Fri Apr 12 14:06:50 2019 +0200 @@ -1478,11 +1478,20 @@ # we don't differenciate URLs finishing with '/' or not del request.postpath[-1] + # i18n if C.KEY_LANG in request.args: try: - session_data.locale = request.args.pop(C.KEY_LANG)[0] + locale = request.args.pop(C.KEY_LANG)[0] except IndexError: log.warning(u"empty lang received") + else: + if u"/" in locale: + # "/" is refused because locale may sometime be used to access + # path, if localised documents are available for instance + log.warning(_(u'illegal char found in locale ("/"), hack ' + u'attempt? locale={locale}').format(locale=locale)) + locale = None + session_data.locale = locale d = defer.Deferred()