elixirdrops / kerosene

Pagination for Ecto and Pheonix.
https://github.com/elixirdrops/kerosene
MIT License
231 stars 39 forks source link

Negative or invalid page number will likely return an exception from the database #31

Open nicolasblanco opened 7 years ago

nicolasblanco commented 7 years ago

Hello!

Maybe that's related to #20, for me the library should by default protect the application and validate that the URL params like page look valid.

I've discovered that changing the page param to -1 or other negative value is still passed to the database and is likely to return a 500 exception. Same for passing a string to the page URL params returns a 500 (Bad argument).

In my humble opinion, if page param does not look like a positive integer it should maybe be considered to be 1 by default (the same as not passing the page param). Or maybe we could return a custom exception (?).

Thanks!

allyraza commented 7 years ago

it is indeed related to https://github.com/elixirdrops/kerosene/issues/20, We need to check for for a lower possible value (<0) and values above max_pages which is set in the config file. I have not had the time to look into this been busy but I will take a look at it this week. if you like to send PR I will appreciate that. Thank you

allyraza commented 7 years ago

I have pushed a patch for this please can you pull it from github and test if it works as expected