|
|
@ -181,19 +181,30 @@ func handleSandboxView(sandbox string, origin string, w http.ResponseWriter, r * |
|
|
|
w.Header().Set("Expires", "-1") |
|
|
|
w.Header().Set("Expires", "-1") |
|
|
|
w.Header().Set("Cache-Control", "private, max-age=0") |
|
|
|
w.Header().Set("Cache-Control", "private, max-age=0") |
|
|
|
|
|
|
|
|
|
|
|
//w.Header().Set("Content-Security-Policy", config.contentSecurityPolicy)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
sandboxTemplateName := fmt.Sprintf("%s_sandbox.html", sandbox) |
|
|
|
sandboxTemplateName := fmt.Sprintf("%s_sandbox.html", sandbox) |
|
|
|
|
|
|
|
|
|
|
|
// Prepare context to deliver to HTML..
|
|
|
|
// Prepare context to deliver to HTML..
|
|
|
|
if t := templates.Lookup(sandboxTemplateName); t != nil { |
|
|
|
if t := templates.Lookup(sandboxTemplateName); t != nil { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CSP support for sandboxes.
|
|
|
|
|
|
|
|
var csp string |
|
|
|
|
|
|
|
switch sandbox { |
|
|
|
|
|
|
|
case "odfcanvas": |
|
|
|
|
|
|
|
csp = fmt.Sprintf("default-src 'none'; script-src %s; img-src data: blob:; style-src 'unsafe-inline'", origin) |
|
|
|
|
|
|
|
case "pdfcanvas": |
|
|
|
|
|
|
|
csp = fmt.Sprintf("default-src 'none'; script-src %s 'unsafe-eval'; img-src 'self' data: blob:; style-src 'unsafe-inline'", origin) |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
csp = "default-src 'none'" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
w.Header().Set("Content-Security-Policy", csp) |
|
|
|
|
|
|
|
|
|
|
|
// Prepare context to deliver to HTML..
|
|
|
|
// Prepare context to deliver to HTML..
|
|
|
|
context := &Context{Cfg: config, Origin: origin} |
|
|
|
context := &Context{Cfg: config, Origin: origin, Csp: true} |
|
|
|
err = t.Execute(w, &context) |
|
|
|
err := t.Execute(w, &context) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
http.Error(w, "404 Unknown Sandbox", http.StatusNotFound) |
|
|
|
http.Error(w, "404 Unknown Sandbox", http.StatusNotFound) |
|
|
|
} |
|
|
|
} |
|
|
|