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

Fix url encoding for PKs with url-unsafe characters (like slashes) #134

Merged
merged 1 commit into from
Sep 30, 2023

Conversation

brewingcode
Copy link
Contributor

If a PK has slashes (eg, a file path), they are not encoded properly and break Flask routing. For example, a PK value of /tmp/foo will route to /table_name/update/tmp/foo.

Flask provides url_map.converters['path'] for this, EXCEPT that the path converter still won't touch a leading slash, which needs to be encoded for this particular example.

Rather than worrying about what characters need to be url-encoded, or whether they are at the start or end of a param, etc, just base64 the PK value so no matter what is in there, it's url-safe.

http:https://exploreflask.com/en/latest/views.html#custom-converters

If a PK has slashes (eg, a file path), they are not encoded properly and
break Flask routing. For example, a PK value of `/tmp/foo` will route to
`/table_name/update/tmp/foo`.

Flask provides `url_map.converters['path']` for this, EXCEPT that the
`path` converter still won't touch a leading slash, which needs to be
encoded for this particular example.

Rather than worrying about what characters need to be url-encoded, or
whether they are at the start or end of a param, etc, just base64 the PK
value so no matter what is in there, it's url-safe.

http:https://exploreflask.com/en/latest/views.html#custom-converters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants