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 PathUtil handling of spaces in file names #9305
Conversation
@@ -185,6 +185,7 @@ public void Resolve(string path, string expected) | |||
} | |||
|
|||
[TestCase(@"C:\WORK\", @"GitExtensions\", @"C:\WORK\GitExtensions\")] | |||
[TestCase(@"C:\WORK\", @" file.txt", @"C:\WORK\ file.txt")] |
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.
Can you please add a testcase for trailing space as well as space before/after /?
(could be in this string)
I
[TestCase(@"C:\WORK\", @" file.txt", @"C:\WORK\ file.txt")] | |
[TestCase(@"C:\WORK\", @" file.txt ", @"C:\WORK\ file.txt ")] | |
[TestCase(@"C:\WORK\", @" \ dir \ file.txt ", @"C:\WORK\ \ dir \ file.txt ")] |
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.
Changed it to @" file .txt "
. From my limited testing it seems that a space at the end of a file name is not possible in Windows but is possible under Linux.
If this is broken in 3.5 and working in 3.4, a separate PR should be submitted to 3.5 |
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 FullPathResolverTests.Resolve_should_return_full_path
fails for the almost-64K path:
System.UriFormatException : Invalid URI: The Uri string is too long.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri.CreateUri(Uri baseUri, String relativeUri, Boolean dontEscape)
at System.Uri..ctor(Uri baseUri, String relativeUri)
at GitCommands.PathUtil.ResolveRelativePath(String path, String relativePath) in C:\projects\gitextensions\GitCommands\PathUtil.cs:line 153
at GitCommands.PathUtil.Resolve(String path, String relativePath) in C:\projects\gitextensions\GitCommands\PathUtil.cs:line 121
at GitCommands.FullPathResolver.Resolve(String path) in C:\projects\gitextensions\GitCommands\FullPathResolver.cs:line 65
at GitCommandsTests.FullPathResolverTests.Resolve_should_return_full_path(String path) in C:\projects\gitextensions\UnitTests\GitCommands.Tests\FullPathResolverTests.cs:line 48
What would be an acceptable limit of the maximum path length supported?
260 chars ;)
|
Is this PR changing the behavior for relative paths? |
I don't think that it does.. the limit for path length (after some googling) seems to be a puny 260 chars for Windows and 4096 for Linux so a test-case with 64KB worth of path is an overkill :) |
It seems that Linux has a limit of 4096 so going much beyond that is not necessary but since I don't know how to choose this arbitrary limit I simply shortened that test-case to still fit the resulting path into 64KB |
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.
Did the second proposed test case with spaces in folder names fail?
Uff, I've completely misread the proposed diff and took a second line as something which has already existed so didn't even read it :D now that I see it, the test case passes just fine but I am more hesitant to include it as a |
Please send a matching PR to 3.5 branch |
(cherry picked from commit f0fe571)
Proposed changes
Screenshots
Test methodology
Test environment(s)
✒️ I contribute this code under The Developer Certificate of Origin.