Skip to content

Bug with encoded characters in a URL #485

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

Closed
kmhoover opened this issue Jan 24, 2023 · 3 comments · Fixed by #491
Closed

Bug with encoded characters in a URL #485

kmhoover opened this issue Jan 24, 2023 · 3 comments · Fixed by #491
Labels
area/contrib Indicates an issue on contrib area. kind/bug/confirmed

Comments

@kmhoover
Copy link

I have a test copied below that fiales with dealing with URL "fragments", or encoded characters in a URL. However in https://github.com/p1c2u/openapi-core/blob/c24f046957fb1dc822cdb6dac0ca7fa3439723e1/openapi_core/contrib/requests/requests.py#L54

The library itself yields only the path, and not the path AND the resulting fragment from the urlparse result in
https://github.com/p1c2u/openapi-core/blob/c24f046957fb1dc822cdb6dac0ca7fa3439723e1/openapi_core/contrib/requests/requests.py#L32

.yml file
EncodedPathVal:
in: path
name: encoded_path_val
required: true
schema:
type: string
pattern: "^#[0-9a-zA-Z][0-9a-zA-Z_.]+$"

Test case
import urllib.parse
import pytest
TEST_EVENT_ENCODED = {
**TEST_EVENT,
"path": urllib.parse.quote("/encoded/#test_encoded"),
}

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 26, 2023

Hi @kmhoover

interesting, if you use urllib.parse.quote it should work fine, isn't it?

@kmhoover
Copy link
Author

The issue is when the first character of the pattern is a '#'. When passed into openapi_core.templating.paths.finders.PathFinder, the path_pattern will be set to none instead of "^#[0-9a-zA-Z][0-9a-zA-Z_.]+$". I created a pull request to see the bug. This works in version 0.14, but not 0.15, or 0.16

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 27, 2023

Git it now. Indeed it is an issue and It should be easy to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/contrib Indicates an issue on contrib area. kind/bug/confirmed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants