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

Add leniency in trailing slash to better accommodate instances mounted in subdirectories #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

memst
Copy link

@memst memst commented Jan 30, 2023

If 0x0 is mounted in a subdirectory of a domain, e.g. https://example.com/0x0, e.g. via:

$ uwsgi --socket 0.0.0.0:80 --protocol=http --manage-script-name --mount /0x0=fhost:app

the welcome message gives non-working commands:

THE NULL POINTER
================

HTTP POST files here:
    curl -F'[email protected]' http://example.com/0x0
<...>
$ curl -F'[email protected]' http://example.com/0x0
<!doctype html>
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="http://example.com/0x0/">http://example.com/0x0/</a>. If not, click the link.

The issue is that flask is expecting to see a trailing slash in such URLs, but it is explicitly removed inside index.html. We can confirm that adding a trailing slash solves the issue:

$ curl -F'[email protected]' http://example.com/0x0/
http://example.com/0x0/E.png

There are two solutions: either add the trailing slash for all urls in index.html, or allow leniency in the presence of a trailing slash by adding strict_slashes=False:

@app.route("/", methods=["GET", "POST"], strict_slashes=False)

anomius pushed a commit to Lochaa/0x0 that referenced this pull request Mar 11, 2023
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.

1 participant