MCPcopy Create free account
hub / github.com/cli/cli / stripControl

Function stripControl

pkg/iostreams/untrusted.go:88–95  ·  view source on GitHub ↗

stripControl is a defensive fallback used only if the sanitizing transform errors, which the asciisanitizer does not do in practice. It drops C0 control bytes other than tab, newline, and carriage return so the result can never carry an escape sequence.

(s string)

Source from the content-addressed store, hash-verified

86// bytes other than tab, newline, and carriage return so the result can never
87// carry an escape sequence.
88func stripControl(s string) string {
89 return strings.Map(func(r rune) rune {
90 if r < 0x20 && r != '\t' && r != '\n' && r != '\r' {
91 return -1
92 }
93 return r
94 }, s)
95}

Callers 2

StringMethod · 0.85

Calls 1

MapMethod · 0.80

Tested by 1