-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
os: fix join_path and join_path_singe to respect absolute paths #21752
Conversation
@@ -26,7 +26,7 @@ fn test_join_path() { | |||
assert os.join_path('foo/bar', './file.txt') == r'foo\bar\file.txt' | |||
assert os.join_path('/opt/v', './x') == r'\opt\v\x' | |||
assert os.join_path('v', 'foo/bar', 'dir') == r'v\foo\bar\dir' | |||
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'v\foo\bar\baz\dir' | |||
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'/dir' |
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.
Shouldn't it be r'v\foo\bar\baz\dir'
?
@@ -40,14 +40,14 @@ fn test_join_path() { | |||
assert os.join_path('foo/bar', './file.txt') == 'foo/bar/file.txt' | |||
assert os.join_path('/opt/v', './x') == '/opt/v/x' | |||
assert os.join_path('/foo/bar', './.././file.txt') == '/foo/bar/../file.txt' | |||
assert os.join_path('v', 'foo/bar\\baz', '/dir') == r'v/foo/bar/baz/dir' | |||
assert os.join_path('v', 'foo/bar\\baz', '/dir') == '/dir' |
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.
And here v/foo/bar/baz/dir
.
} | ||
} | ||
|
||
fn test_join_path_single() { | ||
assert os.join_path_single('', '') == '' | ||
assert os.join_path_single('', './b') == 'b' | ||
assert os.join_path_single('', '/b') == 'b' | ||
assert os.join_path_single('', '/b') == '/b' |
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.
I believe it should be r'/b'
instead.
The later arguments to join_path are relative and not absolute. |
Fixes issue #21751 where by absolute paths in second and subsequent arguments in
join_path
andjoin_path_single
were treated as relative paths instead of absolute paths.Required changing several tests in join_path_text.v, which made incorrect assertions about join_path responses.