A few more locations to disallow template based searches

This commit is contained in:
Kovid Goyal 2026-02-06 16:41:18 +05:30
parent fdab1d476a
commit 3f7fc2cf5b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 4 deletions

View File

@ -33,7 +33,7 @@ def fts_search(ctx, rd):
ans['query_id'] = qid
book_ids = None
if rd.query.get('restriction'):
book_ids = db.search('', restriction=rd.query.get('restriction'))
book_ids = db.search('', restriction=rd.query.get('restriction'), allow_templates=False)
def add_metadata(result):
result.pop('id', None)

View File

@ -86,7 +86,7 @@ class Context:
restriction = self.restriction_for(request_data, db)
if restriction:
try:
return book_id in db.search('', restriction=restriction)
return book_id in db.search('', restriction=restriction, allow_templates=False)
except ParseException:
return False
return db.has_id(book_id)
@ -95,12 +95,12 @@ class Context:
restriction = self.restriction_for(request_data, db)
allowed_book_ids = None
if restriction:
allowed_book_ids = db.search('', restriction=restriction)
allowed_book_ids = db.search('', restriction=restriction, allow_templates=False)
return db.newly_added_book_ids(count=count, book_ids=allowed_book_ids)
def get_allowed_book_ids_from_restriction(self, request_data, db):
restriction = self.restriction_for(request_data, db)
return frozenset(db.search('', restriction=restriction)) if restriction else None
return frozenset(db.search('', restriction=restriction, allow_templates=False)) if restriction else None
def allowed_book_ids(self, request_data, db):
try: