fix(db): validate order param in get_institutions_page

Matches the existing defensive guard in get_journals_page. The current
ternary is safe via ORM (.asc() / .desc() only), but the explicit
allowlist prevents future refactors from accidentally interpolating a
tainted value into raw SQL.
This commit is contained in:
LearningCircuit
2026-04-19 11:58:06 +02:00
parent cf5453703c
commit 23b57a0542

View File

@@ -764,6 +764,13 @@ class JournalQualityDB:
if not self.available:
return [], 0
# Defensive allowlist — matches the pattern in get_journals_page.
# The ternary below is already safe (non-"desc" falls through to
# .asc()), but the explicit check prevents future refactors from
# accidentally interpolating a tainted value into SQL.
if order not in ("asc", "desc"):
order = "desc"
wheres = []
if search:
needle = _escape_like(search.lower().strip()[:_MAX_SEARCH_LEN])