MCPcopy Create free account
hub / github.com/github/gh-aw / applySanitizePattern

Function applySanitizePattern

pkg/stringutil/sanitize.go:160–169  ·  view source on GitHub ↗

applySanitizePattern removes or replaces characters not in the allowed set. When the caller has requested preservation of special chars, unwanted chars are replaced with hyphens; otherwise they are removed entirely.

(result, allowedChars string, preserveSpecialChars bool)

Source from the content-addressed store, hash-verified

158// When the caller has requested preservation of special chars, unwanted chars are
159// replaced with hyphens; otherwise they are removed entirely.
160func applySanitizePattern(result, allowedChars string, preserveSpecialChars bool) string {
161 pattern, ok := sanitizePatterns[allowedChars]
162 if !ok {
163 pattern = regexp.MustCompile(`[^` + allowedChars + `]+`)
164 }
165 if preserveSpecialChars {
166 return pattern.ReplaceAllString(result, "-")
167 }
168 return pattern.ReplaceAllString(result, "")
169}
170
171// SanitizeErrorMessage removes potential secret key names from error messages to prevent
172// information disclosure via logs. This prevents exposing details about an organization's

Callers 1

SanitizeNameFunction · 0.85

Calls 1

MustCompileMethod · 0.80

Tested by

no test coverage detected