coleifer / sqlite-web

Web-based SQLite database browser written in Python
MIT License
3.35k stars 331 forks source link

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

Closed brewingcode closed 11 months ago

brewingcode commented 11 months ago

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://exploreflask.com/en/latest/views.html#custom-converters