Skip to content

request.fullpath is not unescaped when used with grape and swagger ui #107

Description

@code-bunny

Looks like we are hoping the request.full_path is good by default for returning. However I've found some libraries and especially calls from swagger ui will escape query strings. This means when we are creating links they'll come in their escaped form into the response:

  "links": {
    "self": "http://localhost:3000/api/bundles?page%5Bnumber%5D=2",
    "current": "http://localhost:3000/api/bundles?page[number]=2",
    "first": "http://localhost:3000/api/bundles?page[number]=1",
    "prev": "http://localhost:3000/api/bundles?page[number]=1"
  }

This appears to only be present in the pagination and could be corrected by just wrapping it in a CGI.unescape block.

    # Generates the pagination links
    #
    # @return [Array]
    def jsonapi_pagination(resources)
      links = { self: request.base_url + CGI.unescape(request.fullpath) }
      pagination = jsonapi_pagination_meta(resources)

Before opening a PR, is there a specific reason we wouldn't want to CGI.unescape a path here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions