File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -50,19 +50,19 @@ func CleanPath(path string) string {
5050
5151 // Ensure that all paths are cleaned (especially problematic ones like
5252 // "/../../../../../" which can cause lots of issues).
53- path = filepath .Clean (path )
53+
54+ if filepath .IsAbs (path ) {
55+ return filepath .Clean (path )
56+ }
5457
5558 // If the path isn't absolute, we need to do more processing to fix paths
5659 // such as "../../../../<etc>/some/path". We also shouldn't convert absolute
5760 // paths to relative ones.
58- if ! filepath .IsAbs (path ) {
59- path = filepath .Clean (string (os .PathSeparator ) + path )
60- // This can't fail, as (by definition) all paths are relative to root.
61- path , _ = filepath .Rel (string (os .PathSeparator ), path )
62- }
61+ path = filepath .Clean (string (os .PathSeparator ) + path )
62+ // This can't fail, as (by definition) all paths are relative to root.
63+ path , _ = filepath .Rel (string (os .PathSeparator ), path )
6364
64- // Clean the path again for good measure.
65- return filepath .Clean (path )
65+ return path
6666}
6767
6868// stripRoot returns the passed path, stripping the root path if it was
You can’t perform that action at this time.
0 commit comments