pub fn sanitize(s: &str) -> StringExpand description
Replace every character that could forge the shape of a digest with a space, so a value read out of the graph cannot fake a line break, a section header, or a terminal escape sequence — and cannot reorder or hide what it sits next to when rendered.
Three classes, and each is the class rather than the examples: neutralising only U+202E would leave U+202D, and only U+2028 would leave U+0085.
- ASCII controls
0x00-0x1fand0x7f, tabs and newlines included. - Line and paragraph separators outside ASCII: U+0085, U+2028, U+2029.
- Bidi controls and zero-width characters: U+200B-U+200F, U+202A-U+202E, U+2066-U+2069, U+FEFF. These reorder or conceal rendered text without changing the bytes a reader would diff.
One char in, one char out, so a caller’s character budget is unaffected and the byte length can only shrink — never grow.