ignore bad page numbers
-
Mislav
- Assigned user changed from Chris Wanstrath to Mislav
- State changed from new to hold
It is supposed to bomb. It's invalid input, after all. The only way it could happen is nasty spiders or corrupted links.
If it defaulted to page 1, then the following URLs will resolve to a same resource:
/index?page=1 /index?page=0 /index?page=foobar /index?page=anything...I don't think that's correct behavior. When asking for an invalid page number, you should get a 404 or 500. If you were using Rails 2, you would get a 404 by default with will_paginate 2.2.2. But, with Rails 1.2 you are required to handle the InvalidPage error manually with rescue_action_in_public or something like that. You can turn it to a 404 with several extra lines in ApplicationController.
As for page too high, right now it doesn't bomb because I haven't felt that's necessary. An empty collection is returned and there are no results displayed in the view for the user. He can then click on any of the existing page numbers.
Any developer can make too large page numbers bomb by raising a custom error after checking WillPaginate::Collection#out_of_bounds? method.
-
Mislav
- State changed from hold to invalid
- Tag set to page, will_paginate
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.