Skip to content

Commit 07c8c8e

Browse files
committed
parse: clean path after checking if entry is a FullType
The spec[1] doesn't mention anything about cleaning paths, but it does explicitly refer to the path containing a "/". Cleaning the path before checking if the entry is a FullType would result in the simplest way of forcing directories to be FullTypes (appending a "/" to the pathname of any directory) not working with go-mtree. [1]: https://man.netbsd.org/mtree.5 Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 63dc31a commit 07c8c8e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: parse.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
7575

7676
// parse the options
7777
f := strings.Fields(str)
78-
e.Name = filepath.Clean(f[0])
78+
e.Name = f[0]
7979
e.Keywords = StringToKeyVals(f[1:])
8080
// TODO: gather keywords if using tar stream
8181
var isDir bool
@@ -97,6 +97,10 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
9797
creator.curEnt = &e
9898
}
9999
e.Set = creator.curSet
100+
// we need to clean the filepath at the end because '/'s can be
101+
// stripped, which would cause FullTypes to be treated as
102+
// RelativeTypes above
103+
e.Name = filepath.Clean(e.Name)
100104
default:
101105
// TODO(vbatts) log a warning?
102106
continue

0 commit comments

Comments
 (0)