mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
Fix uncontrolled path expression in ExpandHomeDir (#816)
This commit is contained in:
parent
acdc58877f
commit
a369381c4e
@ -59,7 +59,7 @@ func ExpandHomeDir(pathStr string) string {
|
|||||||
if pathStr == "~" {
|
if pathStr == "~" {
|
||||||
return homeDir
|
return homeDir
|
||||||
}
|
}
|
||||||
return filepath.Join(homeDir, pathStr[2:])
|
return filepath.Clean(filepath.Join(homeDir, pathStr[2:]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReplaceHomeDir(pathStr string) string {
|
func ReplaceHomeDir(pathStr string) string {
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@ -223,7 +224,7 @@ func handleLocalStreamFile(w http.ResponseWriter, r *http.Request, fileName stri
|
|||||||
// use the custom response writer
|
// use the custom response writer
|
||||||
rw := ¬FoundBlockingResponseWriter{w: w, headers: http.Header{}}
|
rw := ¬FoundBlockingResponseWriter{w: w, headers: http.Header{}}
|
||||||
// Serve the file using http.ServeFile
|
// Serve the file using http.ServeFile
|
||||||
http.ServeFile(rw, r, fileName)
|
http.ServeFile(rw, r, filepath.Clean(fileName))
|
||||||
// if the file was not found, serve the transparent GIF
|
// if the file was not found, serve the transparent GIF
|
||||||
log.Printf("got streamfile status: %d\n", rw.status)
|
log.Printf("got streamfile status: %d\n", rw.status)
|
||||||
if rw.status == http.StatusNotFound {
|
if rw.status == http.StatusNotFound {
|
||||||
|
Loading…
Reference in New Issue
Block a user