Tallguy297 / SimpleHTTPServerWithUpload

Simple HTTP Server With Upload written in Python 3
131 stars 58 forks source link

Invalid URL (ends with "/None") #11

Closed tsjnachos117 closed 2 years ago

tsjnachos117 commented 2 years ago

Whenever I upload a file, the Back button doesn't really take me back. Instead, it takes me to 127.0.0.1/None. I'm guessing it's because my browser doesn't send referer headers?

Rather than depending on on referers, you could try sending users to a URL that ends in /., as that will send the user to the current url, acting as a kind of POST-free refresh.

Please change line 98 in SimpleHTTPServerWithUpload.py to the following:

        f.write(("<br><br><a href=\"%s\">" % '.').encode())

An ordinary browser should treat that dot as invalid, and discard it, and bring you back to the dir listing page. Assuming you were accessing this server from 127.0.0.1:8000, the Back button will take you to 127.0.0.1:8000 everytime.

Edit: Better yet, use this:

        f.write(("<br><br><a href=\".\">").encode())
Tallguy297 commented 2 years ago

What browser are you using? I have used several browsers, Edge, Firefox, Chrome and haven't had any problems.

tsjnachos117 commented 2 years ago

I'm using Pale Moon, which is derived from Firefox. However, this is a CUSTOM setting, as Pale Moon has the same DEFAULT setting as Firefox. Basically, I tweaked certain options in about:config, which is the reason why I'm experiencing this bug. The changes I described above make the server immune to said bug.