Skip to content
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

Clean on go1.20 #2406

Merged
merged 3 commits into from Feb 21, 2023
Merged

Clean on go1.20 #2406

merged 3 commits into from Feb 21, 2023

Conversation

aldas
Copy link
Contributor

@aldas aldas commented Feb 21, 2023

Go 1.20 "silently" changed how filepath.Clean works on Windows. This is not backported to 1.19.6 etc. Now we need todo some extra hoops to get static mw things work as they used to and securely

// As of 1.20 on Windows filepath.Clean has different behaviour on OS related filesystems so we need to use path.Clean
// which is more suitable for path coming from web but this has some caveats on Windows. When we eventually end up in
// os related filesystem Open methods we are getting different errors as earlier versions. As of 1.20 path checks are
// more strict on path you provide and consider path with [UNC](https://en.wikipedia.org/wiki/Path_(computing)#UNC)
// but missing host etc parts as invalid. Previously it would result you `fs.ErrNotExist`.
//
// So for 1.20@Windows we need to consider it as same not exist so we can continue next middleware/handler and not error
// which would result status 500 instead of potential route hit or 404.

….20. Use path.Clean instead with some workaround related to errors.
@aldas
Copy link
Contributor Author

aldas commented Feb 21, 2023

@lammel please review

@aldas aldas requested a review from lammel February 21, 2023 10:32
@codecov
Copy link

codecov bot commented Feb 21, 2023

Codecov Report

Base: 92.80% // Head: 92.84% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (558bf90) compared to base (b888a30).
Patch coverage: 63.63% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2406      +/-   ##
==========================================
+ Coverage   92.80%   92.84%   +0.03%     
==========================================
  Files          38       39       +1     
  Lines        4506     4503       -3     
==========================================
- Hits         4182     4181       -1     
+ Misses        236      234       -2     
  Partials       88       88              
Impacted Files Coverage Δ
middleware/static.go 69.23% <55.55%> (+0.42%) ⬆️
middleware/static_other.go 100.00% <100.00%> (ø)
echo.go 95.47% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@lammel lammel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

middleware/context_timeout_test.go Outdated Show resolved Hide resolved
middleware/static.go Show resolved Hide resolved
middleware/static_windows.go Show resolved Hide resolved
@aldas aldas merged commit 7c75310 into labstack:master Feb 21, 2023
@aldas aldas deleted the clean_on_go1_20 branch July 22, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants