-
Notifications
You must be signed in to change notification settings - Fork 978
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 Issue #337 and Partially Fix #338 #392
base: master
Are you sure you want to change the base?
Conversation
Ensures that, if the root path is an empty string, the library will not try to take a substring of the file name (and causing the first character to be truncated).
For icsharpcode#337: removes the changes to path based on current working directory. This prevents issues where files that are below the current working directly will behave differently than those that aren't. For icsharpcode#338: Simply removes the code that would remove leading forward slashes from paths. This should unbreak absolute POSIX paths, and avoid the issue where RootPath wouldn't work, though it does allow unc paths (which were previously blocked) as a potential side effect. Part of the issue with icsharpcode#338 is any changes to the path, as part of the TarEntry's GetFileTarHeader have the potential to break RootPath, so you can't simply check for UNC path names there and modify.
It should be possible to fix this without allowing absolute paths. If we really want to add support for them, they should have to be explicitly be turned on since they are usually not intended or wanted (GNU tar strips them if not The name "cleaning" should of course be done in the same name on both sides of the equality check. |
@@ -404,14 +408,6 @@ public void GetFileTarHeader(TarHeader header, string file) | |||
|
|||
name = name.Replace(Path.DirectorySeparatorChar, '/'); | |||
|
|||
// No absolute pathnames |
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.
Not a viable solution.
@@ -379,10 +379,14 @@ public void GetFileTarHeader(TarHeader header, string file) | |||
string name = file; | |||
|
|||
// 23-Jan-2004 GnuTar allows device names in path where the name is not local to the current directory | |||
// 04-Apr-2019 Removed this block, as it creates different behavior based the location of the executing | |||
// assembly. | |||
/* |
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.
The purpose of this block is to do exactly that. While I do agree that this may not belong here, just removing it will just break code relying on this behaviour.
Removes GetCurrentDirectory checks from TarEntry, ensuring that behavior of adding files is consistent, regardless of the current assembly location (resolves #337).
Also removes the check for leading slashes, which prevents absolute paths on POSIX systems from being properly stored. This partially fixes #338, but not completely, as it also means UNC paths are unblocked (an unintended side effect of the fix).
I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.