Merge pull request #7645 from opf/fix/30930/reject-non-integer-zero-page-sizes

[30930] Reject non integer, zero page sizes

[ci skip]
pull/7649/head
Oliver Günther 5 years ago committed by GitHub
commit 2b6459e637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      lib/api/decorators/offset_paginated_collection.rb

@ -39,8 +39,10 @@ module API
def initialize(models, self_link, query: {}, page: nil, per_page: nil, current_user:) def initialize(models, self_link, query: {}, page: nil, per_page: nil, current_user:)
@self_link_base = self_link @self_link_base = self_link
@query = query @query = query
@page = page || 1 @page = page.to_i > 0 ? page.to_i : 1
@per_page = [per_page || self.class.per_page_default(models), maximum_page_size].min @per_page = [per_page || self.class.per_page_default(models), maximum_page_size]
.map(&:to_i)
.min
full_self_link = make_page_link(page: @page, page_size: @per_page) full_self_link = make_page_link(page: @page, page_size: @per_page)
paged = paged_models(models) paged = paged_models(models)

Loading…
Cancel
Save