Fix XSS vulnerabilities in snippet annotations and plugin template
Change-Id: I7cd476e4cddc785eff465d6f5595bdbbe8aa9f45
diff --git a/mapper/response.go b/mapper/response.go
index 3ac6b02..61ff94b 100644
--- a/mapper/response.go
+++ b/mapper/response.go
@@ -2,6 +2,7 @@
import (
"fmt"
+ "html"
"maps"
"strings"
@@ -253,7 +254,7 @@
annotated := escapeXMLText(trimmed)
for i := len(annotationStrings) - 1; i >= 0; i-- {
- annotated = fmt.Sprintf(`<span title="%s" class="notinindex">%s</span>`, annotationStrings[i], annotated)
+ annotated = fmt.Sprintf(`<span title="%s" class="notinindex">%s</span>`, html.EscapeString(annotationStrings[i]), annotated)
}
result.WriteString(annotated)
result.WriteString(trailingWS)