Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc output directory structure leaks home directory structure #18370

Open
gmjosack opened this issue Oct 27, 2014 · 10 comments
Open

rustdoc output directory structure leaks home directory structure #18370

gmjosack opened this issue Oct 27, 2014 · 10 comments
Labels
A-reproducibility Area: Reproducible / Deterministic builds C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@gmjosack
Copy link
Contributor

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 added a commit to lifthrasiir/rust that referenced this issue Dec 1, 2014
Before: doc/src/collections/home/lifthrasiir/git/rust/src/libcollections/vec.rs.html
After: doc/src/collections/vec.rs.html

If the source code is in the parent dirs relative to the crate root,
`..` is replaced with `up` as expected. Any other error like non-UTF-8
paths or drive-relative paths falls back to the absolute path.

There might be a way to improve on false negatives, but this alone
should be enough for fixing rust-lang#18370.
bors added a commit that referenced this issue Dec 1, 2014
…excrichton

Before: `doc/src/collections/home/lifthrasiir/git/rust/src/libcollections/vec.rs.html`
After: `doc/src/collections/vec.rs.html`

If the source code is in the parent dirs relative to the crate root, `..` is replaced with `up` as expected. Any other error like non-UTF-8 paths or drive-relative paths falls back to the absolute path.

There might be a way to improve on false negatives, but this alone should be enough for fixing #18370.
@lifthrasiir
Copy link
Contributor

I think this is fixed by #19436.

@alexcrichton
Copy link
Member

Thanks @lifthrasiir!

@gmjosack
Copy link
Contributor Author

gmjosack commented Dec 3, 2014

Thanks @lifthrasiir !

@devsnek
Copy link
Contributor

devsnek commented Nov 3, 2020

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.

@pietroalbini pietroalbini reopened this Nov 5, 2020
@jyn514 jyn514 added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 5, 2020
@jyn514
Copy link
Member

jyn514 commented Nov 5, 2020

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

@jyn514 jyn514 added the C-bug Category: This is a bug. label Nov 5, 2020
@GuillaumeGomez
Copy link
Member

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

@jyn514
Copy link
Member

jyn514 commented Nov 6, 2020

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
Copy link
Contributor

devsnek commented Nov 6, 2020

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

@jyn514
Copy link
Member

jyn514 commented Apr 8, 2021

@jyn514
Copy link
Member

jyn514 commented Apr 8, 2021

I'm not sure this is rustdoc's fault - it does the same thing for build scripts as for anything else:

let filename = item.span.filename(self.sess());

Maybe there's some bug in span_to_filename?
pub fn span_to_filename(&self, sp: Span) -> FileName {
self.lookup_char_pos(sp.lo()).file.name.clone()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reproducibility Area: Reproducible / Deterministic builds C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants