Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path parameters are not validated properly when they are encoded #17

Open
florentchauveau opened this issue Apr 7, 2024 · 0 comments · May be fixed by #18
Open

Path parameters are not validated properly when they are encoded #17

florentchauveau opened this issue Apr 7, 2024 · 0 comments · May be fixed by #18

Comments

@florentchauveau
Copy link

florentchauveau commented Apr 7, 2024

Hello,

For a simple spec like this one:

  /resource/{param}:
    get:
      operationId: getMaxLengthResourceParameter
      parameters:
        - name: param
          in: path
          required: true
          schema:
            type: string
            maxLength: 1
      responses:
        "204":
          description: success

and an HTTP request to /resource/%2B, the validation fails, although it should not. It fails because parameters are given in their encoded form to openapi3filter. In this case, it passes %2B for validation, and because it is longer than 1, it fails.

It should pass + to openapi3filter.

This is because route, pathParams, err := router.FindRoute(req) returns encoded pathParams. It does so because gorillamux.NewRouter(swagger) uses mux.NewRouter().UseEncodedPath() itself.

I am working on a PR fixing this.

florentchauveau added a commit to florentchauveau/echo-middleware that referenced this issue Apr 7, 2024
florentchauveau added a commit to florentchauveau/echo-middleware that referenced this issue Apr 7, 2024
Parameters should be unscaped before being sent for validation.
gorillamux returns escaped parameters, but openapi3filter expects
unescaped parameters.
florentchauveau added a commit to florentchauveau/echo-middleware that referenced this issue Apr 8, 2024
florentchauveau added a commit to florentchauveau/echo-middleware that referenced this issue Apr 8, 2024
Parameters should be unscaped before being sent for validation.
gorillamux returns escaped parameters, but openapi3filter expects
unescaped parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant