neoascetic / rawgithack

Serves files from github, bitbucket and gitlab, but with the correct content types
https://raw.githack.com
MIT License
577 stars 89 forks source link

Redirect loop after requesting a URL with a double slash #62

Closed mstange closed 3 years ago

mstange commented 3 years ago

This URL responds with a redirect loop: https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/sys/windows/thread.rs

This happened after I initially opened it with an extra slash (note the double slash before library): https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974//library/std/src/sys/windows/thread.rs

It seems that some bad state is cached.

I can reproduce this with arbitrary other URLs, if the initial request to them contains the extra slash. Once the bad state is cached, the URL is "poisoned". For example, I confirmed this with https://rawcdn.githack.com/rust-lang/rust/88f19c6dab716c6281af7602e30f413e809c5974/library/std/src/sys/unix/alloc.rs .

neoascetic commented 3 years ago

Hey! Thanks for the report. I've fixed it.

The problem was with the merge_slashes Nginx's directive which does not do redirect and with Cloudflare behaviour which also does not care about slashes in its cache. So now rawgithack does a redirect if it sees extra slashes (per each such "group"), so there could be extra redirects.

Please feel free to reopen the issue if it does not work for you.

neoascetic commented 3 years ago

Oh, and by the way, you can purge the cache of your "poisoned" URLs on the home page

mstange commented 3 years ago

Wow, that was fast! Thanks! It's working great now.