rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.46k stars 12.73k forks source link

rustdoc output directory structure leaks home directory structure #18370

Open gmjosack opened 10 years ago

gmjosack commented 10 years ago

Since Rust-CI has been continuously failing I've been looking to move my docs to GitHub Pages. This led me to notice that when rustdoc is called with an absolute path as input (as cargo does) the files in doc/src will show your entire home directory layout.

This is problematic not only because of the leak of someone's home directory layout, but because those links will break if I build from a new directory, a new computer, and a different contributor commits those changes. Also if you have 2+ contributors you're going to have massive churn on a repo checking in those files. Least importantly the URLs are ugly when clicking on a src link. :)

As an example on Rust's own API docs, If you click the [src] link on http://doc.rust-lang.org/std/vec/ you end up at http://doc.rust-lang.org/src/collections/home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libcollections/vec.rs.html#11-2901

lifthrasiir commented 9 years ago

I think this is fixed by #19436.

alexcrichton commented 9 years ago

Thanks @lifthrasiir!

gmjosack commented 9 years ago

Thanks @lifthrasiir !

devsnek commented 4 years ago

This appears to be a problem again. I'm seeing stuff like

<a class='srclink' href='../../src/msfs/home/snek/Desktop/projects/msfs-rs/target/debug/build/msfs-7d0246a486c664b1/out/bindings.rs.html#3101' title='goto source code'>[src]</a>

in my output.

jyn514 commented 4 years ago

That looks like it's specific to files generated by build scripts, I haven't seen it for most pages.

GuillaumeGomez commented 4 years ago

Isn't it possible only for local builds? On docs.rs and hosted docs, it shouldn't be possible, no?

jyn514 commented 4 years ago

Hmm, I thought it was possible on docs.rs, but looking at https://docs.rs/zstd-sys/1.4.17+zstd.1.4.5/zstd_sys/struct.ZSTD_DDict_s.html it looks like the file path is not leaked. I could have sworn I'd seen this on docs.rs before, though.

devsnek commented 4 years ago

What does docs.rs do differently so that this doesn't occur? @GuillaumeGomez

jyn514 commented 3 years ago

Triage: This is happening on docs.rs too: https://docs.rs/mbedtls-sys-auto/2.26.0/src/mbedtls_sys/opt/rustwide/target/debug/build/mbedtls-sys-auto-bbf58e089d61f478/out/bindings.rs.html

jyn514 commented 3 years ago

I'm not sure this is rustdoc's fault - it does the same thing for build scripts as for anything else: https://github.com/rust-lang/rust/blob/010c2368fa33ef08df3080228498db8d2ba5a93b/src/librustdoc/html/sources.rs#L48 Maybe there's some bug in span_to_filename? https://github.com/rust-lang/rust/blob/010c2368fa33ef08df3080228498db8d2ba5a93b/compiler/rustc_span/src/source_map.rs#L473-L475