Skip to main content

sanitize

Function sanitize 

Source
pub fn sanitize(text: &str) -> String
Expand description

Text from a repository, made safe to hand a terminal.

A name or a command in amont.conf is chosen by whoever wrote the repository, and the trust prompt exists precisely so a person can read the declarations before accepting them. \x1b[8m is the conceal attribute: putting it in one declaration’s name HID THE NEXT ONE from that prompt, so the reader saw two declarations, pressed y, and got three. The trust model was never bypassed — the rendering lied about what was being trusted, which is the same outcome by a shorter route.

What is escaped, and why each:

  • C0 (< 0x20) — ESC starts every sequence; CR redraws the line; BEL, backspace and the rest are all display control. TAB becomes a single space instead, because these strings sit in aligned columns and a real tab would break the layout it is trying to preserve.
  • DEL and C1 (0x80..=0x9f) — a terminal in 8-bit mode takes 0x9b as CSI directly, with no ESC in sight.
  • The bidi overrides (U+202A..=202E, U+2066..=2069) and the directional marks — “Trojan Source”: they reorder what is displayed without changing a byte of what is parsed.

Everything else passes through untouched, including all other UTF-8 and emoji: this is a display guard, not a charset policy.