CGI fixes

Signed-off-by: kim (grufwub) <grufwub@gmail.com>
development
kim (grufwub) 4 years ago
parent aedd30eb81
commit 45f9f92a66

@ -18,14 +18,10 @@ type RequestRemap struct {
// compileCGIRegex takes a supplied string and returns compiled regular expression
func compileCGIRegex(cgiDir string) *regexp.Regexp {
if path.IsAbs(cgiDir) {
if !strings.HasPrefix(cgiDir, Root) {
SystemLog.Fatalf(cgiDirOutsideRootStr)
}
} else {
cgiDir = path.Join(Root, cgiDir)
SystemLog.Fatalf(cgiDirNotRelativeStr)
}
SystemLog.Infof(cgiDirStr, cgiDir)
return regexp.MustCompile("^" + cgiDir + "(|/.*)$")
return regexp.MustCompile("^" + cgiDir + "(/.*)?$")
}
// compileRestrictedPathsRegex turns a string of restricted paths into a slice of compiled regular expressions
@ -109,9 +105,9 @@ func compileRequestRemapRegex(remaps []string) []*RequestRemap {
return requestRemaps
}
// withinCGIDirEnabled returns whether a Path's absolute value matches within the CGI dir
// withinCGIDirEnabled returns whether a Path's relative value matches within the CGI dir
func withinCGIDirEnabled(p *Path) bool {
return cgiDirRegex.MatchString(p.Selector())
return cgiDirRegex.MatchString(p.Relative())
}
// withinCGIDirDisabled always returns false, CGI is disabled

@ -50,7 +50,7 @@ const (
cgiPathStr = "CGI safe path: %s"
cgiSupportEnabledStr = "CGI script support enabled"
cgiSupportDisabledStr = "CGI script support disabled"
cgiDirOutsideRootStr = "CGI directory must not be outside server root!"
cgiDirNotRelativeStr = "CGI directory must be a relative path!"
cgiDirStr = "CGI directory: %s"
cgiExecuteErrStr = "Exit executing: %s [%d]"

Loading…
Cancel
Save