From 12c8f8f29c9a858a99a5977c1ba6d3999025a073 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 13 May 2017 18:05:55 +0530 Subject: [PATCH] Fix library restriction not fully case-insensitive --- src/calibre/srv/tests/auth.py | 2 +- src/calibre/srv/users.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/calibre/srv/tests/auth.py b/src/calibre/srv/tests/auth.py index 8fde82c62b..d515b89065 100644 --- a/src/calibre/srv/tests/auth.py +++ b/src/calibre/srv/tests/auth.py @@ -147,7 +147,7 @@ class TestAuth(BaseTest): self.assertRaises(HTTPForbidden, get_library, 'xxx') um.add_user('a', 'a') self.assertEqual(library_info('a')[0], {'l%d'%i:'l%d'%i for i in range(1, 4)}) - um.update_user_restrictions('a', {'blocked_library_names': ['l2']}) + um.update_user_restrictions('a', {'blocked_library_names': ['L2']}) self.assertEqual(library_info('a')[0], {'l%d'%i:'l%d'%i for i in range(1, 4) if i != 2}) um.update_user_restrictions('a', {'allowed_library_names': ['l3']}) self.assertEqual(library_info('a')[0], {'l%d'%i:'l%d'%i for i in range(1, 4) if i == 3}) diff --git a/src/calibre/srv/users.py b/src/calibre/srv/users.py index 04ba9e7ff4..54aa506a89 100644 --- a/src/calibre/srv/users.py +++ b/src/calibre/srv/users.py @@ -28,8 +28,8 @@ def parse_restriction(raw): r = load_json(raw) if not isinstance(r, dict): r = {} - r['allowed_library_names'] = frozenset(r.get('allowed_library_names', ())) - r['blocked_library_names'] = frozenset(r.get('blocked_library_names', ())) + r['allowed_library_names'] = frozenset(map(lambda x: x.lower(), r.get('allowed_library_names', ()))) + r['blocked_library_names'] = frozenset(map(lambda x: x.lower(), r.get('blocked_library_names', ()))) return r