mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-08 00:37:27 +00:00
Merge pull request #2426 from foot/support-dot-prefixed-paths
Add support for Kustomizations with dot-prefixed paths
This commit is contained in:
commit
7a306e69ab
2 changed files with 11 additions and 1 deletions
|
|
@ -41,7 +41,10 @@ func (p *SafeRelativePath) Set(str string) error {
|
|||
return fmt.Errorf("invalid relative path '%s': %w", cleanP, err)
|
||||
}
|
||||
// NB: required, as a secure join of "./" will result in "."
|
||||
cleanP = fmt.Sprintf("./%s", strings.TrimPrefix(cleanP, "."))
|
||||
if cleanP == "." {
|
||||
cleanP = ""
|
||||
}
|
||||
cleanP = fmt.Sprintf("./%s", cleanP)
|
||||
*p = SafeRelativePath(cleanP)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,13 @@ func TestRelativePath_Set(t *testing.T) {
|
|||
{"traversing absolute path", "/foo/../bar", "./bar", false},
|
||||
{"traversing overflowing absolute path", "/foo/../../../bar", "./bar", false},
|
||||
{"empty", "", "./", false},
|
||||
{"relative empty path", "./", "./", false},
|
||||
{"double relative empty path", "././", "./", false},
|
||||
{"dot path", ".foo", "./.foo", false},
|
||||
{"relative dot path", "./.foo", "./.foo", false},
|
||||
{"current directory", ".", "./", false},
|
||||
{"parent directory", "..", "./", false},
|
||||
{"parent directory more qualified", "./..", "./", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue