fix Utilities.ResolvePath for relative paths#36
Conversation
|
There was an additional error with Path.GetFullPath which produces a path starting with the current working dir, if the basePath does not start with '\'. |
LordMike
left a comment
There was a problem hiding this comment.
I've just realized the entire path-manipulating-layer might be riddled with bugs.. :/
|
|
||
| if (!basePath.EndsWith(@"\")) | ||
| basePath = Path.GetDirectoryName(basePath); | ||
|
|
There was a problem hiding this comment.
I don't think we can do this. On Linux and Windows, Path.* might give different results. An example is GetFileName.
On Windows, for a Windows path, it will return a file name as expected. But on linux, a Windows path will give you the whole path, and not just the name. The reason is the directory seperators which for Windows contain both variants ("" and "/") - on linux, only "/" is present.
There was a problem hiding this comment.
I can see other parts of this code works on the ""-premise, but for new code we need to be careful.
| if (path.Length > 0 && path[0] != '\\') | ||
| { | ||
| path = '\\' + path; | ||
| } |
There was a problem hiding this comment.
In principle we have Path.IsRooted - but we need to consider OS-specifics here.
| <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> | ||
| <PublicSign>true</PublicSign> | ||
| <SignAssembly>True</SignAssembly> | ||
| <AssemblyOriginatorKeyFile>../../SigningKey.snk</AssemblyOriginatorKeyFile> |
There was a problem hiding this comment.
Huh... Didn't realize tests weren't signed.. Oh well :P
| CheckResolvePath(@"\etc\rc.d\", @"init.d", @"\etc\rc.d\init.d"); | ||
| // For example: (\TEMP\Foo.txt, ..\..\Bar.txt) gives (\Bar.txt). | ||
| CheckResolvePath(@"\TEMP\Foo.txt", @"..\..\Bar.txt", @"\Bar.txt"); | ||
| } |
There was a problem hiding this comment.
Do we have tests anywhere for paths going outside the current volume?
|
I found this problem while dumping a whole fs tree to validate my btrfs implementation. To be sure it's actually a bug, I reproduced this on xfs and ext. |
Fixes an error with resolving relative symlinks pointing to a target inside the same directory.
Example: