feat: add browser upload queue and trusted sessions with bounded projections
Build and publish container images / images (push) Successful in 11m37s
Release container images / release (push) Successful in 22s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 20:27:04 +09:00
1 parent 84d52390f9
commit b90aef79d0
79 files changed
+1962 -196

No files matched your search

+15 -2
View File
@@ -20,11 +20,11 @@ import (
"golang.org/x/net/html/atom"
)
const htmlProjectionVersion = "controlled-v2"
const htmlProjectionVersion = "controlled-v3"
const maxProjectionInput = 1 << 20
const maxProjectionOutput = 4 << 20
var projectionMacroRE = regexp.MustCompile(`\{\{(?:children[^}]*|(?:city-breadcrumbs|spot-pages|quartier|street|spot|nearby|city)(?:\s+[^}]*)?)\}\}`)
var projectionMacroRE = regexp.MustCompile(`\{\{(?:csv:[^}]*|children[^}]*|(?:city-breadcrumbs|spot-pages|quartier|street|spot|nearby|city)(?:\s+[^}]*)?)\}\}`)
var languageClassRE = regexp.MustCompile(`^language-[a-zA-Z0-9_+-]{1,40}$`)
func projectionPolicy(generated bool) *bluemonday.Policy {
@@ -199,6 +199,8 @@ func (s *Server) safeHTMLProjection(r *http.Request, body, path string, expand b
}
var output strings.Builder
macros, count := 0, 0
csvCount := 0
csvResults := map[string]string{}
var emit func(*html.Node, int, bool) bool
emit = func(n *html.Node, depth int, literal bool) bool {
count++
@@ -226,6 +228,14 @@ func (s *Server) safeHTMLProjection(r *http.Request, body, path string, expand b
// be reparsed as a nested children request on its raw text.
if isAnonymousProjection(r) {
expanded = s.expandPublicMacro(r, macro, path)
} else if strings.HasPrefix(macro, "{{csv:") {
if cached, ok := csvResults[macro]; ok {
expanded = cached
} else if csvCount < 4 {
csvCount++
expanded = s.expandCSVMacro(r, macro)
csvResults[macro] = expanded
}
} else if strings.HasPrefix(macro, "{{children") {
expanded = s.expandChildrenMacros(macro, path)
} else {
@@ -236,6 +246,9 @@ func (s *Server) safeHTMLProjection(r *http.Request, body, path string, expand b
// promote decoded entities into trusted generated elements.
output.WriteString(stdhtml.EscapeString(macro))
} else {
if output.Len()+len(expanded) > maxProjectionOutput {
return false
}
output.WriteString(expanded)
}
at = loc[1]