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

Fix to_file_path for relative paths with drive letters #442

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matklad
Copy link

@matklad matklad commented Apr 3, 2018

Hi!

I've recently hit this debug assertion on windows for paths like file://C:.

I've added a couple of tests and a "fix", which just turns the assertion into error. I have no idea how to fix this properly.


This change is Reviewable

fn to_file_path_for_relative_windows_paths() {
if cfg!(windows) {
let url = Url::parse("file://example.com/C:foo").unwrap();
assert!(url.to_file_path().is_ok());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: unlike other tests, this is ok. I would think that it should be err as well, but std::Path disagrees with me and insists that \\exaple.com\C:foo is an absolute path. Is this a bug in stdlib maybe as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@retep998 perhaps you know? Consider this program:

use std::path::PathBuf;

fn main() {
    let p1 = PathBuf::from(r"C:foo");
    let p2 = PathBuf::from(r"\\example.com\C:foo");
    println!("{} {}", p1.is_absolute(), p2.is_absolute());
}

It currently prints false true. Is this the correct behavior?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C:foo is relative to the current directory for the C drive. \\example.com\C:foo is a UNC path which is absolute.

For more information on the types of paths... https://googleprojectzero.blogspot.com/2016/02/the-definitive-guide-on-win32-to-nt.html

@matklad
Copy link
Author

matklad commented Aug 29, 2018

ping @SimonSapin :-)

I don't feel a pressing need for this or anything, but this issue seems somewhat interesting, because it arguably allows to sneak in relative path in release build, which might be security sensitive?

@SimonSapin SimonSapin mentioned this pull request Oct 17, 2018
42 tasks
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #517) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants