package fbhttp
import (
"net/http"
"strings"
)
// URL.Path has already been decoded once by net/http. Refuse alternate
// separators and residual escapes rather than interpreting a second time.
func validSharePath(p string) bool {
if strings.ContainsAny(p, "\\%\x00:") {
return false
}
depth := 0
for i, part := range strings.Split(p, "/") {
if i == 0 {
continue
}
if part == ".." {
depth--
if depth < 0 {
return false
}
} else if part != "" && part != "." {
depth++
}
}
return true
}
// This empty, credential-free shell is the only place user scripts execute.
// A response CSP (not an editable meta tag) survives document.write. The opaque
// sandbox origin cannot read cookies, storage, or the File Browser parent.
func publicLandingShell(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("Referrer-Policy", "no-referrer")
w.Header().Set("X-Content-Type-Options", "nosniff")
w.Header().Set("Content-Security-Policy", "sandbox allow-scripts; default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src blob: data:; media-src blob: data:; font-src data:; connect-src 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'self'")
_, _ = w.Write([]byte(``))
}