mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-24 09:05:39 +00:00
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 <cyphar@cyphar.com>
This commit is contained in:
parent
63dc31a80a
commit
07c8c8e17a
1 changed files with 5 additions and 1 deletions
6
parse.go
6
parse.go
|
@ -75,7 +75,7 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
|
|||
|
||||
// parse the options
|
||||
f := strings.Fields(str)
|
||||
e.Name = filepath.Clean(f[0])
|
||||
e.Name = f[0]
|
||||
e.Keywords = StringToKeyVals(f[1:])
|
||||
// TODO: gather keywords if using tar stream
|
||||
var isDir bool
|
||||
|
@ -97,6 +97,10 @@ func ParseSpec(r io.Reader) (*DirectoryHierarchy, error) {
|
|||
creator.curEnt = &e
|
||||
}
|
||||
e.Set = creator.curSet
|
||||
// we need to clean the filepath at the end because '/'s can be
|
||||
// stripped, which would cause FullTypes to be treated as
|
||||
// RelativeTypes above
|
||||
e.Name = filepath.Clean(e.Name)
|
||||
default:
|
||||
// TODO(vbatts) log a warning?
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue