-
Notifications
You must be signed in to change notification settings - Fork 333
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
base: main
Are you sure you want to change the base?
Conversation
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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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? |
☔ The latest upstream changes (presumably #517) made this pull request unmergeable. Please resolve the merge conflicts. |
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