This commit is contained in:
Hedy Li 2021-08-02 12:46:07 +08:00
parent c34697e1cc
commit 274db2f289
Signed by: hedy
GPG Key ID: B51B5A8D1B176372
2 changed files with 8 additions and 8 deletions

View File

@ -15,7 +15,7 @@ import (
"time"
)
func handleCGI(conf *Config, req *Request, cgiPath string) (ok bool){
func handleCGI(conf *Config, req *Request, cgiPath string) (ok bool) {
ok = true
path := req.filePath
conn := req.conn

View File

@ -18,11 +18,11 @@ import (
)
type Request struct {
conn io.ReadWriteCloser
netConn *net.Conn
user string
path string // Requested path
filePath string // Actual file path that does not include the content dir name
conn io.ReadWriteCloser
netConn *net.Conn
user string
path string // Requested path
filePath string // Actual file path that does not include the content dir name
}
const (
@ -139,7 +139,7 @@ func handleConnection(netConn net.Conn, conf *Config) {
return
}
break // CGI failed. just handle the request as if it's a static file.
break // CGI failed. just handle the request as if it's a static file.
}
}
@ -163,7 +163,7 @@ func resolvePath(reqPath string, conf *Config, req *Request) (path string) {
// /~user/ and have duplicate results, although in that case the search should handle
// omitting duplicates...
}
req.filePath = strings.TrimPrefix(filepath.Clean(strings.TrimPrefix(reqPath, "/~" + username)), "/")
req.filePath = strings.TrimPrefix(filepath.Clean(strings.TrimPrefix(reqPath, "/~"+username)), "/")
new_prefix := filepath.Join("/home/", username, conf.UserDir)
req.user = username
path = filepath.Clean(strings.Replace(reqPath, bits[1], new_prefix, 1))