Fix to_file_path for relative paths with drive letters#442
Fix to_file_path for relative paths with drive letters#442matklad wants to merge 1 commit intoservo:mainfrom
to_file_path for relative paths with drive letters#442Conversation
| 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.
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.
@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.
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