fix(server): allowlist dir param in page.server.ts
Mirrors the existing sort allowlist pattern. Any value other than 'asc' or 'desc' silently falls back to 'desc', preventing arbitrary strings from reaching the search API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,12 @@ export async function load({ url, fetch }) {
|
||||
const sort: ValidSort = (VALID_SORTS as readonly string[]).includes(rawSort)
|
||||
? (rawSort as ValidSort)
|
||||
: 'DATE';
|
||||
const dir = url.searchParams.get('dir') || 'desc';
|
||||
const VALID_DIRS = ['asc', 'desc'] as const;
|
||||
type ValidDir = (typeof VALID_DIRS)[number];
|
||||
const rawDir = url.searchParams.get('dir') ?? 'desc';
|
||||
const dir: ValidDir = (VALID_DIRS as readonly string[]).includes(rawDir)
|
||||
? (rawDir as ValidDir)
|
||||
: 'desc';
|
||||
const tagQ = url.searchParams.get('tagQ') || '';
|
||||
|
||||
const isDashboard = !q && !from && !to && !senderId && !receiverId && !tags.length && !tagQ;
|
||||
|
||||
Reference in New Issue
Block a user