|
|
|
@ -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
|
|
|
|
|