mirror of
https://github.com/go-gitea/gitea.git
synced 2024-10-01 03:36:12 -04:00
filepath, logging modification
This commit is contained in:
parent
4d72886b00
commit
c1f075931b
@ -5,7 +5,7 @@ package setting
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"path/filepath"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
)
|
)
|
||||||
@ -18,8 +18,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func isValidFileName(filename string) error {
|
func isValidFileName(filename string) error {
|
||||||
if strings.Contains(filename, "/") || strings.Contains(filename, "\\") {
|
if filepath.Base(filename) != filename || filepath.IsAbs(filename) || filename == "." || filename == ".." {
|
||||||
return fmt.Errorf("contains path components")
|
return fmt.Errorf("can only contain filenames, not other directories")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -31,12 +31,12 @@ func loadHooksFrom(rootCfg ConfigProvider) {
|
|||||||
GitHookPostreceiveName = githooks.Key("GIT_HOOK_POSTRECEIVE_NAME").MustString("post-receive")
|
GitHookPostreceiveName = githooks.Key("GIT_HOOK_POSTRECEIVE_NAME").MustString("post-receive")
|
||||||
|
|
||||||
if err := isValidFileName(GitHookPrereceiveName); err != nil {
|
if err := isValidFileName(GitHookPrereceiveName); err != nil {
|
||||||
log.Fatal("Invalid git pre-receive hook name (%s): %v", GitHookPrereceiveName, err)
|
log.Fatal("'%s' is an invalid [git.hooks].GIT_HOOK_PRERECEIVE_NAME: %v", GitHookPrereceiveName, err)
|
||||||
}
|
}
|
||||||
if err := isValidFileName(GitHookUpdateName); err != nil {
|
if err := isValidFileName(GitHookUpdateName); err != nil {
|
||||||
log.Fatal("Invalid git update hook name (%s): %v", GitHookUpdateName, err)
|
log.Fatal("'%s' is an invalid [git.hooks].GIT_HOOK_UPDATE_NAME: %v", GitHookUpdateName, err)
|
||||||
}
|
}
|
||||||
if err := isValidFileName(GitHookPostreceiveName); err != nil {
|
if err := isValidFileName(GitHookPostreceiveName); err != nil {
|
||||||
log.Fatal("Invalid git post-receive hook name (%s): %v", GitHookPostreceiveName, err)
|
log.Fatal("'%s' is an invalid [git.hooks].GIT_HOOK_POSTRECEIVE_NAME: %v", GitHookPostreceiveName, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user