mirror of
https://github.com/ceph/ceph
synced 2025-03-25 11:48:05 +00:00
Merge pull request #42183 from SMIL-Infra/fix-ac-lang
mgr/dashboard: fix Accept-Language header parsing
This commit is contained in:
commit
ffdd2bbbb6
@ -58,7 +58,7 @@ class LanguageMixin(object):
|
||||
class HomeController(BaseController, LanguageMixin):
|
||||
LANG_TAG_SEQ_RE = re.compile(r'\s*([^,]+)\s*,?\s*')
|
||||
LANG_TAG_RE = re.compile(
|
||||
r'^(?P<locale>[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})?)(;q=(?P<weight>[01]\.\d{0,3}))?$')
|
||||
r'^(?P<locale>[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*|\*)(;q=(?P<weight>[01]\.\d{0,3}))?$')
|
||||
MAX_ACCEPTED_LANGS = 10
|
||||
|
||||
@lru_cache()
|
||||
|
@ -64,3 +64,10 @@ class HomeTest(ControllerTestCase, FakeFsMixin):
|
||||
self.assertStatus(200)
|
||||
logger.info(self.body)
|
||||
self.assertIn('<html lang="en">', self.body.decode('utf-8'))
|
||||
|
||||
@mock.patch(FakeFsMixin.builtins_open, new=FakeFsMixin.f_open)
|
||||
@mock.patch('os.stat', new=FakeFsMixin.f_os.stat)
|
||||
@mock.patch('os.listdir', new=FakeFsMixin.f_os.listdir)
|
||||
def test_home_multiple_subtags_lang(self):
|
||||
self._get('/', headers=[('Accept-Language', 'zh-Hans-CN')])
|
||||
self.assertStatus(200)
|
||||
|
Loading…
Reference in New Issue
Block a user