Skip to content

Directory listing accepts invalid page numbers #296

Description

@forgou37

The GET /api/directory endpoint parses the page query parameter without clamping it to a valid range.

Repro

GET /api/directory?page=-1

Observed:

  • page = parseInt("-1") = -1 (truthy, so the || 1 fallback is skipped)
  • offset = (-1 - 1) * 20 = -40
  • Supabase .range(-40, -21) call returns a database error (500)

Fix

Clamp page to a minimum of 1:

const page = Math.max(1, parseInt(url.searchParams.get("page") || "1") || 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions