summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorIlia Tetin <hunternif@gmail.com>2025-03-26 19:15:33 +0000
committerHunternif <hunternif@gmail.com>2025-03-30 18:55:52 +0100
commitaa0b1a2e52b817c8a6014e360fcdf47aa1d33015 (patch)
treed6b6704002aab754c93871eb18adc850a8c46295 /server
parented87754eee8690133d4bdb37de3818c33d3dce38 (diff)
server: prevent cache key collision for unsafe posts
Diffstat (limited to 'server')
-rw-r--r--server/szurubooru/search/configs/post_search_config.py5
-rw-r--r--server/szurubooru/search/executor.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/server/szurubooru/search/configs/post_search_config.py b/server/szurubooru/search/configs/post_search_config.py
index 5bf95d7..222718e 100644
--- a/server/szurubooru/search/configs/post_search_config.py
+++ b/server/szurubooru/search/configs/post_search_config.py
@@ -341,6 +341,11 @@ class PostSearchConfig(BaseSearchConfig):
)
return query.order_by(model.Post.post_id.desc())
+
+ @property
+ def can_list_unsafe(self) -> bool:
+ return self.user and auth.has_privilege(self.user, "posts:list:unsafe")
+
@property
def id_column(self) -> SaColumn:
return model.Post.post_id
diff --git a/server/szurubooru/search/executor.py b/server/szurubooru/search/executor.py
index 5302b14..bf95cc0 100644
--- a/server/szurubooru/search/executor.py
+++ b/server/szurubooru/search/executor.py
@@ -95,7 +95,10 @@ class Executor:
if token.name == "random":
disable_eager_loads = True
- key = (id(self.config), hash(search_query), offset, limit)
+
+ can_list_unsafe = getattr(self.config, "can_list_unsafe", False)
+
+ key = (id(self.config), hash(search_query), offset, limit, can_list_unsafe)
if not disable_eager_loads and cache.has(key):
return cache.get(key)