Fix panic on normalizing path containing .. (#2042)

Fixes #2039
This commit is contained in:
Yusuke Kuoka 2022-01-10 17:45:44 +09:00 committed by GitHub
parent c069fbf268
commit 9e9a90f8ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -2,10 +2,11 @@ package state
import ( import (
"fmt" "fmt"
"go.uber.org/zap"
"net/url" "net/url"
"path/filepath" "path/filepath"
"sort" "sort"
"go.uber.org/zap"
) )
type Storage struct { type Storage struct {
@ -86,7 +87,7 @@ func (st *Storage) ExpandPaths(globPattern string) ([]string, error) {
// normalizes relative path to absolute one // normalizes relative path to absolute one
func (st *Storage) normalizePath(path string) string { func (st *Storage) normalizePath(path string) string {
u, _ := url.Parse(path) u, _ := url.Parse(path)
if u.Scheme != "" || filepath.IsAbs(path) { if u != nil && (u.Scheme != "" || filepath.IsAbs(path)) {
return path return path
} else { } else {
return st.JoinBase(path) return st.JoinBase(path)