iron / staticfile

Static file-serving middleware for the Iron web framework.
MIT License
63 stars 56 forks source link

Avoid extension with empty strings #81

Closed kstrafe closed 8 years ago

kstrafe commented 8 years ago

The empty strings causes the result to become completely empty, the reproduction case contains [""] in the iterator. Due to the path being empty, no file could be downloaded. By filtering the empty paths, we avoid overwriting the original url requesting path.

The example would fail with an internal error because the path ends in "/", whilst we're actually requesting a file name specifically.

Hoverbear commented 8 years ago

Hi there! Can you elaborate more on the error?

I assume you're referring the doc_server example? Can you give an example of what would be a problem?

kstrafe commented 8 years ago

It's the following case,

let mut mount = Mount::new();
mount.mount("/", Static::new(Path::new("Cargo.toml")));
Iron::new(mount).http("localhost:3000").unwrap();

Or simply with

Iron::new(Static::new(Path::new("Cargo.toml"))).http("localhost:3000").unwrap();

I get error 500 from the browser with the 0.3.0 version, the patch doesn't give me this error, can you reproduce this? Cases for "/a/" to Cargo.toml give the same error.

My bad not naming the example, it was the readme example, (last mount for the html file), however, that was partially due to a bug in the old mount iirc.

Hoverbear commented 8 years ago

Confirming this is an issue. Your patch seems to resolve this issue.

Before I merge can you please use the contributing guidelines here?

Hoverbear commented 8 years ago

I'd still love to merge this but I'd prefer it if the commits followed the guidelines.

All you need to do git commit --amend and change the commit message to (fix) Avoid extension with empty strings then git push -f to your branch. Once you'd done that let me know and I'll merge.

kstrafe commented 8 years ago

Did you mean to remove the body of the commit message? I left it in.

Hoverbear commented 8 years ago

Looks good thanks!