静态分发增加例外URL、限制URL、排除隐藏文件等选项

This commit is contained in:
刘祥超
2023-08-10 11:27:24 +08:00
parent d30e2b2cc8
commit f456b6bc6b

View File

@@ -66,6 +66,19 @@ func (this *HTTPRequest) doRoot() (isBreak bool) {
requestPath = this.uri[:questionMarkIndex]
}
// except hidden files
if this.web.Root.ExceptHiddenFiles &&
(strings.Contains(requestPath, "/.") || strings.Contains(requestPath, "\\.")) {
this.write404()
return true
}
// except and only files
if !this.web.Root.MatchURL(this.URL()) {
this.write404()
return true
}
// 去掉其中的奇怪的路径
requestPath = strings.Replace(requestPath, "..\\", "", -1)