ben-xo / dir2cast

Turn a directory of MP3s into a podcast - automatically.
http://www.ben-xo.com/dir2cast
BSD 3-Clause "New" or "Revised" License
152 stars 20 forks source link

Fix double forward slash in the beginning of the path #55

Closed rromanw closed 1 year ago

rromanw commented 2 years ago

When there are two froward slashes in the beginning (it happens) it breaks the paths.

ben-xo commented 2 years ago

Hey @rromanw thanks so much for the contribution!

What's the consequence of having the double slash? It's usually harmless, so where is it causing trouble?

Do you have any steps to reproduce, or perhaps even a test case, or just an example?

From your patch, I'm wary of what happens when something is a symlink, because realpath() also resolves symlinks, which doesn't sound like it would be intentional. And indeed it causes the tests to fail on MacOS (weirdly not on Linux) as you can see.

It might be a better fix to do something like str_replace('//', '/', ...) - but I'm keen to know more about what the real problem is.

ben-xo commented 2 years ago

Also, MP3_BASE is used to create default MP3_DIR, and MP3_DIR is used to compare with DOCUMENT_ROOT to check that we're allowed to read from it for security reasons. So it should match what's in DOCUMENT_ROOT.

This behaviour could probably do with some additional unit tests because that assumption might be totally wrong these days (it was usually true 12 years ago, and I think it might be usually false now)…

ben-xo commented 2 years ago

Hey @rromanw are you able to give me an example of how the double forward slash occurs, and some more information about your setup? Are you using nginx and php-fpm in docker, or some other setup? Can you give me an example of the MP3_BASE with the double forward slash?

ben-xo commented 1 year ago

I think I've fixed this properly in #66