mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 03:02:24 -06:00
Update codeberg.org/gruf libraries and fix go-store issue (#347)
* update codeberg.org/gruf/ libraries Signed-off-by: kim <grufwub@gmail.com> * another update Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
86e8e7fd21
commit
635ad2a42f
15 changed files with 366 additions and 197 deletions
20
vendor/codeberg.org/gruf/go-store/util/fs.go
generated
vendored
20
vendor/codeberg.org/gruf/go-store/util/fs.go
generated
vendored
|
|
@ -9,14 +9,22 @@ import (
|
|||
"codeberg.org/gruf/go-fastpath"
|
||||
)
|
||||
|
||||
var dotdot = "../"
|
||||
// IsDirTraversal will check if rootPlusPath is a dir traversal outside of root,
|
||||
// assuming that both are cleaned and that rootPlusPath is path.Join(root, somePath)
|
||||
func IsDirTraversal(root string, rootPlusPath string) bool {
|
||||
switch {
|
||||
// Root is $PWD, check for traversal out of
|
||||
case root == ".":
|
||||
return strings.HasPrefix(rootPlusPath, "../")
|
||||
|
||||
// CountDotdots returns the number of "dot-dots" (../) in a cleaned filesystem path
|
||||
func CountDotdots(path string) int {
|
||||
if !strings.HasSuffix(path, dotdot) {
|
||||
return 0
|
||||
// The path MUST be prefixed by root
|
||||
case !strings.HasPrefix(rootPlusPath, root):
|
||||
return true
|
||||
|
||||
// In all other cases, check not equal
|
||||
default:
|
||||
return len(root) == len(rootPlusPath)
|
||||
}
|
||||
return strings.Count(path, dotdot)
|
||||
}
|
||||
|
||||
// WalkDir traverses the dir tree of the supplied path, performing the supplied walkFn on each entry
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue