fix: clamp and validate limit and page query params in /api/courses#3166
fix: clamp and validate limit and page query params in /api/courses#3166siddharth277 wants to merge 1 commit into
Conversation
|
@siddharth277 is attempting to deploy a commit to the Prem Shaw's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
📌 Contribution Guidelines Reminder 👋 Thanks for contributing to Learnova! We maintain contribution limits to ensure quality and fair visibility: Your current activity:
Tips for quality contributions: 📖 See our Contribution Guidelines and Discussion Board for more info. Thanks for being a great contributor! 🎉 |
Description
Fixes unvalidated pagination query parameters in GET /api/courses.
Previously, limit and page were parsed with parseInt() and passed directly to getPaginatedCourses() with no bounds checking. This allowed:
-limit=999999 — wasteful computation across the entire dataset
-page=0 / page=-5 — negative startIndex producing incorrect slice results
-limit=abc — parseInt returns NaN, causing slice(NaN, NaN) to silently return [] with no error
Fixes #3165
Type of change
Checklist: