Skip to content

Commit d8caa1c

Browse files
Nemo157Joshua Nelson
authored and
Joshua Nelson
committed
Don't serve non-rustdoc resources from the shared resource handler
1 parent 583382f commit d8caa1c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/web/rustdoc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,10 @@ pub struct SharedResourceHandler;
635635
impl Handler for SharedResourceHandler {
636636
fn handle(&self, req: &mut Request) -> IronResult<Response> {
637637
let path = req.url.path();
638+
if path.len() > 1 {
639+
// All rustdoc shared resources are hosted at the root
640+
return Err(Nope::ResourceNotFound.into());
641+
}
638642
let filename = path.last().unwrap(); // unwrap is fine: vector is non-empty
639643
let suffix = filename.split('.').last().unwrap(); // unwrap is fine: split always works
640644
if ["js", "css", "woff", "svg"].contains(&suffix) {

0 commit comments

Comments
 (0)