fix: list symlinks with abs targets (#37)
parent
ee2b091e7a
commit
e22451dfbf
|
@ -84,14 +84,12 @@ var resourceGetHandler = withUser(func(w http.ResponseWriter, r *http.Request, d
|
||||||
|
|
||||||
// remove symlinks that link outside base path
|
// remove symlinks that link outside base path
|
||||||
if fi.IsSymlink {
|
if fi.IsSymlink {
|
||||||
var fullLinkTarget string
|
link := fi.Link
|
||||||
if filepath.IsAbs(fi.Link) {
|
if !filepath.IsAbs(link) {
|
||||||
fullLinkTarget = fi.Link
|
link = filepath.Join(d.user.FullPath(file.Path), link)
|
||||||
} else {
|
|
||||||
fullLinkTarget = filepath.Join(d.user.FullPath(file.Path), fi.Link)
|
|
||||||
}
|
}
|
||||||
scopedLinkTarget := d.user.FullPath(filepath.Join(file.Path, fi.Link))
|
link = filepath.Clean(link)
|
||||||
if fullLinkTarget != scopedLinkTarget {
|
if !strings.HasPrefix(link, d.server.Root) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue