Skip to content
This repository has been archived by the owner on Oct 4, 2018. It is now read-only.

Commit

Permalink
Ensure page limits are only enforced on bookshelf (fixes #7915)
Browse files Browse the repository at this point in the history
#62 was designed to limit high-paging into bookshelf search requests.
This introduced a regression where all requests that used a `:page` parameter would
fail past the value set for `bookshelf.max_pages` in the settings.
  • Loading branch information
Mark A. Matienzo committed Aug 31, 2015
1 parent e4c23dc commit 782c74a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/controllers/bookshelf_controller.rb
Expand Up @@ -6,6 +6,8 @@ def show
respond_to do |format|
format.json do
# Bookshelf gives a list of books.
raise Errors::PageLimitError if \
params['page'].to_i > Settings.bookshelf.max_pages.to_i
@search = Bookshelf.new *permitted_params.search
@items = @search.result permitted_params.args
render json: @items
Expand Down
5 changes: 1 addition & 4 deletions app/models/permitted_params.rb
Expand Up @@ -27,10 +27,7 @@ def filters(options = {})
def args
args = params.map do |key, value|
case key
when 'page' then
raise Errors::PageLimitError \
if value.to_i > Settings.bookshelf.max_pages.to_i
[key, value]
when 'page' then [key, value]
when 'page_size' then [key, value] if %w(10 20 50 100).include?(value)
when 'sort_by' then [key, value] if %w(title created).include?(value)
when 'sort_order' then [key, value] if %w(asc desc).include?(value)
Expand Down

0 comments on commit 782c74a

Please sign in to comment.