-
Notifications
You must be signed in to change notification settings - Fork 18k
path/filepath: Abs does not call Clean on windows #17210
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
Comments
I agree, we should change windows filepath.Abs to call filepath.Clean before it returns. Maybe add new test from your example (https://play.golang.org/p/mSWVatv4ql) to path/filepath.TestAbs . @PsyWolf would you like to send a change? See https://golang.org/doc/contribute.html for instructions. Maybe wait couple days to see if others object. Thank you. Alex |
Interestingly, the check is already in the test. There just aren't any test cases that triggered it. I'd be happy to contribute a patch if no one minds the potential downstream breakage. |
Ok, this has sat here long enough without objection. I'll start work on a patch. |
@zevdg, did you create the patch? |
Yeah, I did. I just have to get approval from my company's legal to upstream it. Given how trivial this is, I don't anticipate any problem there. |
Ping @zevdg. |
legal approved this today. Will submit this patch tomorrow morning. |
code review at https://go-review.googlesource.com/#/c/32292/ |
CL https://golang.org/cl/32292 mentions this issue. |
The filepath.Abs function in windows did not call Clean as the documentation claimed. This change not only fixes that behavoir but also changes the test function to verify that Clean is called more effectively. Fixes golang#17210 Change-Id: I20c5f5026042fd7bd9d929ff5b17c8b2653f8afe
The filepath.Abs documentation clearly states that "Abs calls Clean on the result", but this is not always true. This was already noticed and mentioned in this comment on issue #16111, but this one quirk seems to have been missed in the patch.
I understand that changing this behavior to match the docs would break any code that depends on the existing implementation. If the implementation cannot be changed, the documentation should at least be updated to match the implementation.
go version: go1.7.1 windows/amd64
Run this code from this playground on windows and linux and compare the output
I expected to see a cleaned result coming out of Abs on windows. I'm using the trailing slash as the indicator that clean was not called.
Instead, I see that Clean was not called by Abs on windows. A quick comparison of the windows and unix implementations of Abs verifies this inconsistency.
The text was updated successfully, but these errors were encountered: