fix: filter all character dangerous sequences internally (#2459)

This commit is contained in:
valoq authored and GitHub committed 2026-03-24 11:58:58 +11:00
1 parent 644b8196bf
commit e363f76601
3 files changed
+31 -2

No files matched your search

+12
View File
@@ -270,3 +270,15 @@ func applyOSC(body string, st tcell.Style) tcell.Style {
return st
}
}
// stripAllSequences removes all control characters from a string, keeping
// only printable characters and tabs. This is used to
// sanitize raw file content for the internal previewer.
func stripAllSequences(s string) string {
return strings.Map(func(r rune) rune {
if r >= 0x20 && r != 0x7F || r == '\t' {
return r
}
return -1
}, s)
}