mirror of
https://github.com/mudler/luet.git
synced 2025-09-19 17:54:29 +00:00
Take count of os separator in extraction
This commit is contained in:
@@ -146,26 +146,27 @@ func ExtractFiles(
|
|||||||
|
|
||||||
return func(h *tar.Header) (bool, error) {
|
return func(h *tar.Header) (bool, error) {
|
||||||
|
|
||||||
|
fileName := filepath.Join(string(os.PathSeparator), h.Name)
|
||||||
switch {
|
switch {
|
||||||
case len(includes) == 0 && len(excludes) != 0:
|
case len(includes) == 0 && len(excludes) != 0:
|
||||||
for _, i := range excludeRegexp {
|
for _, i := range excludeRegexp {
|
||||||
if i.MatchString(filepath.Join(prefixPath, h.Name)) {
|
if i.MatchString(filepath.Join(prefixPath, fileName)) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if prefixPath != "" {
|
if prefixPath != "" {
|
||||||
return strings.HasPrefix(h.Name, prefixPath), nil
|
return strings.HasPrefix(fileName, prefixPath), nil
|
||||||
}
|
}
|
||||||
ctx.Debug("Adding name", h.Name)
|
ctx.Debug("Adding name", fileName)
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|
||||||
case len(includes) > 0 && len(excludes) == 0:
|
case len(includes) > 0 && len(excludes) == 0:
|
||||||
for _, i := range includeRegexp {
|
for _, i := range includeRegexp {
|
||||||
if i.MatchString(filepath.Join(prefixPath, h.Name)) {
|
if i.MatchString(filepath.Join(prefixPath, fileName)) {
|
||||||
if prefixPath != "" {
|
if prefixPath != "" {
|
||||||
return strings.HasPrefix(h.Name, prefixPath), nil
|
return strings.HasPrefix(h.Name, prefixPath), nil
|
||||||
}
|
}
|
||||||
ctx.Debug("Adding name", h.Name)
|
ctx.Debug("Adding name", fileName)
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@@ -173,16 +174,16 @@ func ExtractFiles(
|
|||||||
return false, nil
|
return false, nil
|
||||||
case len(includes) != 0 && len(excludes) != 0:
|
case len(includes) != 0 && len(excludes) != 0:
|
||||||
for _, i := range includeRegexp {
|
for _, i := range includeRegexp {
|
||||||
if i.MatchString(filepath.Join(prefixPath, h.Name)) {
|
if i.MatchString(filepath.Join(prefixPath, fileName)) {
|
||||||
for _, e := range excludeRegexp {
|
for _, e := range excludeRegexp {
|
||||||
if e.MatchString(filepath.Join(prefixPath, h.Name)) {
|
if e.MatchString(filepath.Join(prefixPath, fileName)) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if prefixPath != "" {
|
if prefixPath != "" {
|
||||||
return strings.HasPrefix(h.Name, prefixPath), nil
|
return strings.HasPrefix(fileName, prefixPath), nil
|
||||||
}
|
}
|
||||||
ctx.Debug("Adding name", h.Name)
|
ctx.Debug("Adding name", fileName)
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@@ -190,7 +191,7 @@ func ExtractFiles(
|
|||||||
return false, nil
|
return false, nil
|
||||||
default:
|
default:
|
||||||
if prefixPath != "" {
|
if prefixPath != "" {
|
||||||
return strings.HasPrefix(h.Name, prefixPath), nil
|
return strings.HasPrefix(fileName, prefixPath), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
Reference in New Issue
Block a user