MCPcopy Create free account
hub / github.com/diillson/chatcli / sanitizeForPrompt

Function sanitizeForPrompt

server/handler_analysis.go:164–175  ·  view source on GitHub ↗

sanitizeForPrompt escapes user-provided text to prevent prompt injection. Wraps content in explicit data delimiters so the LLM treats it as data, not instructions.

(text string)

Source from the content-addressed store, hash-verified

162// sanitizeForPrompt escapes user-provided text to prevent prompt injection.
163// Wraps content in explicit data delimiters so the LLM treats it as data, not instructions.
164func sanitizeForPrompt(text string) string {
165 if text == "" {
166 return ""
167 }
168 // Strip common prompt injection patterns
169 dangerous := []string{"<|im_start|>", "<|im_end|>", "<<SYS>>", "<</SYS>>", "[INST]", "[/INST]"}
170 result := text
171 for _, d := range dangerous {
172 result = strings.ReplaceAll(result, d, "[FILTERED]")
173 }
174 return result
175}
176
177func buildAnalysisPrompt(req *pb.AnalyzeIssueRequest) string {
178 var sb strings.Builder

Callers 2

buildAnalysisPromptFunction · 0.85
buildAgenticStepPromptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected