Skip to content

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

Closed
zevdg opened this issue Sep 23, 2016 · 9 comments
Closed

path/filepath: Abs does not call Clean on windows #17210

zevdg opened this issue Sep 23, 2016 · 9 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@zevdg
Copy link
Contributor

zevdg commented Sep 23, 2016

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.

@bradfitz bradfitz added this to the Go1.8 milestone Sep 23, 2016
@alexbrainman
Copy link
Member

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

@zevdg
Copy link
Contributor Author

zevdg commented Sep 24, 2016

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.

@zevdg
Copy link
Contributor Author

zevdg commented Oct 4, 2016

Ok, this has sat here long enough without objection. I'll start work on a patch.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 10, 2016
@rsc
Copy link
Contributor

rsc commented Oct 19, 2016

@zevdg, did you create the patch?

@zevdg
Copy link
Contributor Author

zevdg commented Oct 19, 2016

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.

@rsc
Copy link
Contributor

rsc commented Oct 27, 2016

Ping @zevdg.

@zevdg
Copy link
Contributor Author

zevdg commented Oct 27, 2016

legal approved this today. Will submit this patch tomorrow morning.

@zevdg
Copy link
Contributor Author

zevdg commented Oct 28, 2016

code review at https://go-review.googlesource.com/#/c/32292/

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/32292 mentions this issue.

zevdg added a commit to zevdg/go that referenced this issue Oct 28, 2016
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
@golang golang locked and limited conversation to collaborators Oct 29, 2017
@rsc rsc unassigned zevdg Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

6 participants