Skip to main content

truncate

Function truncate 

Source
pub fn truncate(s: String, max: usize) -> String
Expand description

Truncate to at most max bytes on a word boundary, noting the cut.

#414: a character boundary is not the same as a token boundary. A cutting point that landed inside a secret published half of it — sk-abcdefgh and no more — and no pattern catches that: the sk- rule wants twenty characters of key behind the prefix, so half a key reads as an error message and survives every redaction pass. So the cut backs up to the last separator inside a short window and drops the fragment with it. Losing one word out of a truncated output costs a reader nothing; losing the head of their key to a transcript costs them the key.