Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
1167:7d2e098ea3f4 | 1168:ea0caa7b1bcc |
---|---|
1476 # at the beginning of the request hanling | 1476 # at the beginning of the request hanling |
1477 if request.postpath and not request.postpath[-1]: | 1477 if request.postpath and not request.postpath[-1]: |
1478 # we don't differenciate URLs finishing with '/' or not | 1478 # we don't differenciate URLs finishing with '/' or not |
1479 del request.postpath[-1] | 1479 del request.postpath[-1] |
1480 | 1480 |
1481 # i18n | |
1481 if C.KEY_LANG in request.args: | 1482 if C.KEY_LANG in request.args: |
1482 try: | 1483 try: |
1483 session_data.locale = request.args.pop(C.KEY_LANG)[0] | 1484 locale = request.args.pop(C.KEY_LANG)[0] |
1484 except IndexError: | 1485 except IndexError: |
1485 log.warning(u"empty lang received") | 1486 log.warning(u"empty lang received") |
1487 else: | |
1488 if u"/" in locale: | |
1489 # "/" is refused because locale may sometime be used to access | |
1490 # path, if localised documents are available for instance | |
1491 log.warning(_(u'illegal char found in locale ("/"), hack ' | |
1492 u'attempt? locale={locale}').format(locale=locale)) | |
1493 locale = None | |
1494 session_data.locale = locale | |
1486 | 1495 |
1487 | 1496 |
1488 d = defer.Deferred() | 1497 d = defer.Deferred() |
1489 d.addCallback(self._checkAccess, request) | 1498 d.addCallback(self._checkAccess, request) |
1490 | 1499 |